feat(sensor-placement): add scheme engineering editor

This commit is contained in:
2026-07-30 16:16:51 +08:00
parent 04557b9363
commit d643f09fcf
13 changed files with 2724 additions and 159 deletions
@@ -0,0 +1,73 @@
import { api } from "@/lib/api";
import { config } from "@/config/config";
import type {
AdjustmentStatus,
SensorPlacementScheme,
} from "./types";
export interface OptimizeSchemeInput {
network: string;
scheme_name: string;
sensor_type: "pressure";
method: "sensitivity" | "kmeans";
sensor_count: number;
min_diameter: number;
}
export const optimizeSensorPlacement = async (
input: OptimizeSchemeInput,
): Promise<SensorPlacementScheme> => {
const response = await api.post<SensorPlacementScheme>(
`${config.BACKEND_URL}/api/v1/sensor-placement-schemes/optimize`,
input,
);
return response.data;
};
export const getSensorPlacementScheme = async (
network: string,
schemeId: number,
): Promise<SensorPlacementScheme> => {
const response = await api.get<SensorPlacementScheme>(
`${config.BACKEND_URL}/api/v1/sensor-placement-schemes/${schemeId}`,
{ params: { network } },
);
return response.data;
};
export const overwriteSensorPlacementScheme = async (
network: string,
schemeId: number,
expectedSensorLocation: string[],
sensorLocation: string[],
): Promise<SensorPlacementScheme> => {
const response = await api.put<SensorPlacementScheme>(
`${config.BACKEND_URL}/api/v1/sensor-placement-schemes/${schemeId}`,
{
expected_sensor_location: expectedSensorLocation,
sensor_location: sensorLocation,
},
{ params: { network } },
);
return response.data;
};
export const exportSensorPlacementExcel = async (
network: string,
schemeId: number,
sensorLocation: string[],
adjustmentStatus: Record<string, AdjustmentStatus>,
) => {
const response = await api.post<Blob>(
`${config.BACKEND_URL}/api/v1/sensor-placement-schemes/${schemeId}/exports/excel`,
{
sensor_location: sensorLocation,
adjustment_status: adjustmentStatus,
},
{
params: { network },
responseType: "blob",
},
);
return response.data;
};