refactor(frontend): align TJWater Next integrations

This commit is contained in:
2026-08-26 12:26:29 +08:00
parent 6623f4f7fb
commit fee4fc6ce1
51 changed files with 3074 additions and 22280 deletions
@@ -21,8 +21,11 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import "dayjs/locale/zh-cn";
import dayjs, { Dayjs } from "dayjs";
import { useNotification } from "@refinedev/core";
import { api } from "@/lib/api";
import { NETWORK_NAME, config } from "@config/config";
import {
getAnalysisResults,
getAnalysisScheme,
listAnalysisSchemes,
} from "@/lib/analysisRuns";
import { useControllableObjectState } from "@components/olmap/core/useControllableState";
import { LeakageResultDetail, LeakageSchemeRecord } from "./types";
import { FLOW_DISPLAY_UNIT, toM3h } from "@utils/units";
@@ -40,7 +43,7 @@ interface Props {
export interface DMALeakSchemeQueryState {
queryAll: boolean;
queryDate: Dayjs | null;
expandedId: number | null;
expandedId: string | null;
hasQueried: boolean;
}
@@ -84,16 +87,12 @@ const SchemeQuery: React.FC<Props> = ({
const handleQuery = async () => {
setLoading(true);
try {
const params: Record<string, string> = {
scheme_type: "dma_leak_identification",
};
if (!queryAll && queryDate) {
params.query_date = queryDate.startOf("day").toISOString();
}
const response = await api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params,
});
const nextSchemes = response.data as LeakageSchemeRecord[];
const nextSchemes = (await listAnalysisSchemes({
runType: "dma_leak_identification",
queryDate: !queryAll && queryDate
? queryDate.format("YYYY-MM-DD")
: undefined,
})) as LeakageSchemeRecord[];
setSchemes(nextSchemes);
setQueryField("hasQueried", true);
if (nextSchemes.length === 0) {
@@ -122,22 +121,30 @@ const SchemeQuery: React.FC<Props> = ({
}
};
const handleViewSchemeResult = async (schemeName: string) => {
const handleViewSchemeResult = async (runId: string) => {
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/schemes/${encodeURIComponent(schemeName)}`,
{
params: {
scheme_type: "dma_leak_identification",
},
},
);
onViewResult(response.data as LeakageResultDetail);
const [scheme, results] = await Promise.all([
getAnalysisScheme(runId),
getAnalysisResults(runId, "leakage_identification"),
]);
const result = results[0]?.payload;
if (!result) {
throw new Error("方案详情缺少漏损识别结果");
}
onViewResult({
...result,
scheme_name: scheme.scheme_name,
scheme_detail: scheme.scheme_detail,
scheme_start_time: scheme.scheme_start_time,
create_time: scheme.create_time,
username: scheme.username,
} as LeakageResultDetail);
} catch (error: any) {
open?.({
type: "error",
message: "查看详情失败",
description: error?.response?.data?.detail ?? "无法获取方案详情",
description:
error?.response?.data?.detail ?? error?.message ?? "无法获取方案详情",
});
}
};
@@ -293,7 +300,7 @@ const SchemeQuery: React.FC<Props> = ({
size="small"
className="bg-blue-600 hover:bg-blue-700"
sx={{ textTransform: "none", fontWeight: 500 }}
onClick={() => handleViewSchemeResult(scheme.scheme_name)}
onClick={() => handleViewSchemeResult(scheme.scheme_id)}
>
</Button>
@@ -6,7 +6,7 @@ export interface LeakageRow {
}
export interface LeakageSchemeRecord {
scheme_id: number;
scheme_id: string;
scheme_name: string;
scheme_type: string;
username: string;