修复爆管分析方案创建时,时间向后偏移一分钟的问题;
This commit is contained in:
@@ -7,7 +7,7 @@ export default function Home() {
|
|||||||
return (
|
return (
|
||||||
<div className="relative w-full h-full overflow-hidden">
|
<div className="relative w-full h-full overflow-hidden">
|
||||||
<MapComponent>
|
<MapComponent>
|
||||||
<MapToolbar />
|
<MapToolbar hiddenButtons={["style"]} />
|
||||||
<MonitoringPlaceOptimizationPanel />
|
<MonitoringPlaceOptimizationPanel />
|
||||||
</MapComponent>
|
</MapComponent>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const AnalysisParameters: React.FC = () => {
|
|||||||
|
|
||||||
const [pipePoints, setPipePoints] = useState<PipePoint[]>([]);
|
const [pipePoints, setPipePoints] = useState<PipePoint[]>([]);
|
||||||
const [startTime, setStartTime] = useState<Dayjs | null>(dayjs(new Date()));
|
const [startTime, setStartTime] = useState<Dayjs | null>(dayjs(new Date()));
|
||||||
const [duration, setDuration] = useState<number>(3000);
|
const [duration, setDuration] = useState<number>(3600);
|
||||||
const [schemeName, setSchemeName] = useState<string>(
|
const [schemeName, setSchemeName] = useState<string>(
|
||||||
"FANGAN" + new Date().getTime()
|
"FANGAN" + new Date().getTime()
|
||||||
);
|
);
|
||||||
@@ -52,6 +52,14 @@ const AnalysisParameters: React.FC = () => {
|
|||||||
useState<VectorLayer<VectorSource> | null>(null);
|
useState<VectorLayer<VectorSource> | null>(null);
|
||||||
const [highlightFeatures, setHighlightFeatures] = useState<Feature[]>([]);
|
const [highlightFeatures, setHighlightFeatures] = useState<Feature[]>([]);
|
||||||
const [analyzing, setAnalyzing] = useState<boolean>(false);
|
const [analyzing, setAnalyzing] = useState<boolean>(false);
|
||||||
|
|
||||||
|
// 检查是否所有必要参数都已填写
|
||||||
|
const isFormValid =
|
||||||
|
pipePoints.length > 0 &&
|
||||||
|
startTime !== null &&
|
||||||
|
duration > 0 &&
|
||||||
|
schemeName.trim() !== "";
|
||||||
|
|
||||||
// 初始化管道图层和高亮图层
|
// 初始化管道图层和高亮图层
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!map) return;
|
if (!map) return;
|
||||||
@@ -254,11 +262,11 @@ const AnalysisParameters: React.FC = () => {
|
|||||||
const burst_size = pipePoints.map((pipe) =>
|
const burst_size = pipePoints.map((pipe) =>
|
||||||
parseInt(pipe.area.toString(), 10)
|
parseInt(pipe.area.toString(), 10)
|
||||||
);
|
);
|
||||||
|
// 格式化开始时间,去除秒部分
|
||||||
const modify_pattern_start_time = startTime
|
const modify_pattern_start_time = startTime
|
||||||
? startTime.format("YYYY-MM-DDTHH:mm:ssZ")
|
? startTime.format("YYYY-MM-DDTHH:mm:00Z")
|
||||||
: "";
|
: "";
|
||||||
const modify_total_duration = duration;
|
const modify_total_duration = duration;
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
name: network,
|
name: network,
|
||||||
modify_pattern_start_time: modify_pattern_start_time,
|
modify_pattern_start_time: modify_pattern_start_time,
|
||||||
@@ -464,7 +472,7 @@ const AnalysisParameters: React.FC = () => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
size="large"
|
size="large"
|
||||||
onClick={handleAnalyze}
|
onClick={handleAnalyze}
|
||||||
disabled={analyzing}
|
disabled={analyzing || !isFormValid}
|
||||||
className="bg-blue-600 hover:bg-blue-700"
|
className="bg-blue-600 hover:bg-blue-700"
|
||||||
>
|
>
|
||||||
{analyzing ? "方案提交分析中..." : "方案分析"}
|
{analyzing ? "方案提交分析中..." : "方案分析"}
|
||||||
|
|||||||
@@ -258,13 +258,12 @@ const SCADADataPanel: React.FC<SCADADataPanelProps> = ({
|
|||||||
headerName: deviceLabels?.[id] ?? id,
|
headerName: deviceLabels?.[id] ?? id,
|
||||||
minWidth: 140,
|
minWidth: 140,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
valueFormatter: (params) => {
|
valueFormatter: (value: any) => {
|
||||||
const value = (params as any).value;
|
if (value === null || value === undefined) return "--";
|
||||||
return value === null || value === undefined
|
if (Number.isFinite(Number(value))) {
|
||||||
? "--"
|
return Number(value).toFixed(fractionDigits);
|
||||||
: Number.isFinite(Number(value))
|
}
|
||||||
? Number(value).toFixed(fractionDigits)
|
return String(value);
|
||||||
: String(value);
|
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -305,7 +304,10 @@ const SCADADataPanel: React.FC<SCADADataPanelProps> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const chartSection = hasData ? (
|
const renderChart = () => {
|
||||||
|
if (!hasData) return renderEmpty();
|
||||||
|
|
||||||
|
return (
|
||||||
<LineChart
|
<LineChart
|
||||||
dataset={dataset}
|
dataset={dataset}
|
||||||
height={376}
|
height={376}
|
||||||
@@ -337,20 +339,35 @@ const SCADADataPanel: React.FC<SCADADataPanelProps> = ({
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
renderEmpty()
|
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const tableSection = hasData ? (
|
const renderTable = () => {
|
||||||
|
if (!hasData) return renderEmpty();
|
||||||
|
|
||||||
|
console.debug("[SCADADataPanel] 表格数据:", {
|
||||||
|
rowsCount: rows.length,
|
||||||
|
columnsCount: columns.length,
|
||||||
|
sampleRow: rows[0],
|
||||||
|
columns: columns.map(c => c.field),
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
<DataGrid
|
<DataGrid
|
||||||
rows={rows}
|
rows={rows}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
columnBufferPx={100}
|
columnBufferPx={100}
|
||||||
|
initialState={{
|
||||||
|
pagination: {
|
||||||
|
paginationModel: { pageSize: 10, page: 0 },
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
pageSizeOptions={[5, 10, 25, 50]}
|
||||||
sx={{ border: "none", height: "360px" }}
|
sx={{ border: "none", height: "360px" }}
|
||||||
|
disableRowSelectionOnClick
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
renderEmpty()
|
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
@@ -519,7 +536,7 @@ const SCADADataPanel: React.FC<SCADADataPanelProps> = ({
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{activeTab === "chart" ? chartSection : tableSection}
|
{activeTab === "chart" ? renderChart() : renderTable()}
|
||||||
</Box>
|
</Box>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|||||||
Reference in New Issue
Block a user