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