新增水质分析功能模块
This commit is contained in:
@@ -44,7 +44,7 @@ const AnalysisParameters: React.FC = () => {
|
||||
const [startTime, setStartTime] = useState<Dayjs | null>(dayjs(new Date()));
|
||||
const [duration, setDuration] = useState<number>(3600);
|
||||
const [schemeName, setSchemeName] = useState<string>(
|
||||
"FANGAN" + new Date().getTime()
|
||||
"FANGAN" + new Date().getTime(),
|
||||
);
|
||||
const [network, setNetwork] = useState<string>(NETWORK_NAME);
|
||||
const [isSelecting, setIsSelecting] = useState<boolean>(false);
|
||||
@@ -88,7 +88,7 @@ const AnalysisParameters: React.FC = () => {
|
||||
width: 3,
|
||||
lineDash: [15, 10],
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
const geometry = feature.getGeometry();
|
||||
const lineCoords =
|
||||
@@ -115,7 +115,7 @@ const AnalysisParameters: React.FC = () => {
|
||||
scale: 0.2,
|
||||
anchor: [0.5, 1],
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
return styles;
|
||||
@@ -163,14 +163,14 @@ const AnalysisParameters: React.FC = () => {
|
||||
// 移除不在highlightFeatures中的
|
||||
const filtered = prevPipes.filter((pipe) =>
|
||||
highlightFeatures.some(
|
||||
(feature) => feature.getProperties().id === pipe.id
|
||||
)
|
||||
(feature) => feature.getProperties().id === pipe.id,
|
||||
),
|
||||
);
|
||||
// 添加新的
|
||||
const newPipes = highlightFeatures
|
||||
.filter(
|
||||
(feature) =>
|
||||
!filtered.some((p) => p.id === feature.getProperties().id)
|
||||
!filtered.some((p) => p.id === feature.getProperties().id),
|
||||
)
|
||||
.map((feature) => {
|
||||
const properties = feature.getProperties();
|
||||
@@ -207,7 +207,7 @@ const AnalysisParameters: React.FC = () => {
|
||||
const featureId = feature.getProperties().id;
|
||||
setHighlightFeatures((prev) => {
|
||||
const existingIndex = prev.findIndex(
|
||||
(f) => f.getProperties().id === featureId
|
||||
(f) => f.getProperties().id === featureId,
|
||||
);
|
||||
if (existingIndex !== -1) {
|
||||
// 如果已存在,移除
|
||||
@@ -218,7 +218,7 @@ const AnalysisParameters: React.FC = () => {
|
||||
}
|
||||
});
|
||||
},
|
||||
[map]
|
||||
[map],
|
||||
);
|
||||
|
||||
// 开始选择管道
|
||||
@@ -242,14 +242,14 @@ const AnalysisParameters: React.FC = () => {
|
||||
const handleRemovePipe = (id: string) => {
|
||||
// 从高亮features中移除
|
||||
setHighlightFeatures((prev) =>
|
||||
prev.filter((f) => f.getProperties().id !== id)
|
||||
prev.filter((f) => f.getProperties().id !== id),
|
||||
);
|
||||
};
|
||||
|
||||
const handleAreaChange = (id: string, value: string) => {
|
||||
const numValue = parseFloat(value) || 0;
|
||||
setPipePoints((prev) =>
|
||||
prev.map((pipe) => (pipe.id === id ? { ...pipe, area: numValue } : pipe))
|
||||
prev.map((pipe) => (pipe.id === id ? { ...pipe, area: numValue } : pipe)),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -266,30 +266,26 @@ const AnalysisParameters: React.FC = () => {
|
||||
|
||||
const burst_ID = pipePoints.map((pipe) => pipe.id);
|
||||
const burst_size = pipePoints.map((pipe) =>
|
||||
parseInt(pipe.area.toString(), 10)
|
||||
parseInt(pipe.area.toString(), 10),
|
||||
);
|
||||
// 格式化开始时间,去除秒部分
|
||||
const modify_pattern_start_time = startTime
|
||||
? startTime.format("YYYY-MM-DDTHH:mm:00Z")
|
||||
: "";
|
||||
const modify_total_duration = duration;
|
||||
const body = {
|
||||
name: network,
|
||||
const params = {
|
||||
network: network,
|
||||
modify_pattern_start_time: modify_pattern_start_time,
|
||||
burst_ID: burst_ID,
|
||||
burst_size: burst_size,
|
||||
modify_total_duration: modify_total_duration,
|
||||
scheme_Name: schemeName,
|
||||
scheme_name: schemeName,
|
||||
};
|
||||
|
||||
try {
|
||||
await axios.post(`${config.BACKEND_URL}/api/v1/burst_analysis/`, body, {
|
||||
headers: {
|
||||
"Accept-Encoding": "gzip",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
await axios.get(`${config.BACKEND_URL}/api/v1/burst_analysis/`, {
|
||||
params,
|
||||
});
|
||||
|
||||
// 更新弹窗为成功状态
|
||||
open?.({
|
||||
key: "burst-analysis",
|
||||
|
||||
Reference in New Issue
Block a user