fix:java项目性能优化
This commit is contained in:
@@ -105,7 +105,7 @@ const buildCrossParent = (
|
||||
const observationUnitDbId = optionalText(observationUnitId);
|
||||
if (!parentTypeValue && !germplasmDbId && !observationUnitDbId) return null;
|
||||
if (!parentTypeValue) throw new Error("请为已填亲本选择 parent_type");
|
||||
if (!germplasmDbId && !observationUnitDbId) throw new Error("亲本必须填写 germplasm 或 observation_unit 至少一项");
|
||||
if (!germplasmDbId && !observationUnitDbId) throw new Error("亲本必须填写 germplasm <EFBFBD>?observation_unit 至少一");
|
||||
return {
|
||||
parentType: parentTypeValue as CrossParent["parentType"],
|
||||
...(germplasmDbId ? { germplasmDbId } : {}),
|
||||
@@ -181,23 +181,23 @@ export function buildCrossParentFormState(
|
||||
}
|
||||
|
||||
const crossingProjectBody = (payload: CrossingProjectPayload) => {
|
||||
const programDbId = requiredText(payload.program_id, "请选择所属 Program");
|
||||
const programDbId = requiredText(payload.program_id, "请选择所<EFBFBD>?Program");
|
||||
return {
|
||||
crossingProjectName: requiredText(payload.name, "请填写杂交项目名称"),
|
||||
crossingProjectName: requiredText(payload.name, "请填写杂交项目名"),
|
||||
crossingProjectDescription: optionalText(payload.description),
|
||||
programDbId,
|
||||
};
|
||||
};
|
||||
|
||||
const plannedCrossBody = (payload: PlannedCrossPayload) => ({
|
||||
plannedCrossName: requiredText(payload.name, "请填写计划杂交名称"),
|
||||
plannedCrossName: requiredText(payload.name, "请填写计划杂交名"),
|
||||
crossingProjectDbId: requiredText(payload.crossing_project_id, "请选择杂交项目"),
|
||||
...(optionalText(payload.cross_type) ? { crossType: optionalText(payload.cross_type) } : {}),
|
||||
...(optionalText(payload.status) ? { status: optionalText(payload.status) } : { status: "TODO" }),
|
||||
});
|
||||
|
||||
const crossBody = (payload: CrossPayload) => ({
|
||||
crossName: requiredText(payload.name, "请填写实际杂交名称"),
|
||||
crossName: requiredText(payload.name, "请填写实际杂交名"),
|
||||
crossingProjectDbId: requiredText(payload.crossing_project_id, "请选择杂交项目"),
|
||||
...(optionalText(payload.cross_type) ? { crossType: optionalText(payload.cross_type) } : {}),
|
||||
...(optionalText(payload.planned_cross_id) ? { plannedCrossDbId: optionalText(payload.planned_cross_id) } : {}),
|
||||
@@ -430,7 +430,7 @@ export async function fetchCrossParentRows(): Promise<CrossParentRow[]> {
|
||||
}
|
||||
|
||||
export async function updateCrossParents(payload: CrossParentFormState): Promise<void> {
|
||||
const crossId = requiredText(payload.cross_id, "请选择所属 Cross");
|
||||
const crossId = requiredText(payload.cross_id, "请选择所<EFBFBD>?Cross");
|
||||
const parent1 = buildCrossParent(
|
||||
payload.parent1_type,
|
||||
payload.parent1_germplasm_id,
|
||||
@@ -466,14 +466,14 @@ export async function updateCrossParents(payload: CrossParentFormState): Promise
|
||||
|
||||
export async function fetchPedigreeRows(): Promise<PedigreeRecord[]> {
|
||||
const response = await request<BrapiListResponse<PedigreeRecord & PedigreeNode>>(
|
||||
"/brapi/v2/pedigree?page=0&pageSize=1000",
|
||||
"/brapi/v2/pedigree?page=0&pageSize=10",
|
||||
);
|
||||
return response.result.data.map(mapPedigree);
|
||||
}
|
||||
|
||||
export async function fetchPedigreeRowsWithRelations(): Promise<PedigreeRecord[]> {
|
||||
const response = await request<BrapiListResponse<PedigreeRecord & PedigreeNode>>(
|
||||
"/brapi/v2/pedigree?page=0&pageSize=1000&includeParents=true&includeProgeny=false&includeSiblings=true",
|
||||
"/brapi/v2/pedigree?page=0&pageSize=10&includeParents=true&includeProgeny=false&includeSiblings=true",
|
||||
);
|
||||
return response.result.data.map(mapPedigree);
|
||||
}
|
||||
@@ -481,7 +481,7 @@ export async function fetchPedigreeRowsWithRelations(): Promise<PedigreeRecord[]
|
||||
export async function fetchPedigreeDetail(id: string): Promise<PedigreeRecord> {
|
||||
const rows = await fetchPedigreeRows();
|
||||
const found = rows.find((row) => row.id === id || row.germplasm_id === id);
|
||||
if (!found) throw new Error("系谱节点不存在");
|
||||
if (!found) throw new Error("系谱节点不存");
|
||||
return found;
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ export async function upsertPedigreeEdge(payload: PedigreeEdgeFormState, origina
|
||||
const thisNodeId = requiredText(payload.this_node_id, "请选择当前材料");
|
||||
const connectedNodeId = requiredText(payload.connected_node_id, "请选择关联材料");
|
||||
if (thisNodeId === connectedNodeId) {
|
||||
throw new Error("当前材料与关联材料不能相同");
|
||||
throw new Error("当前材料与关联材料不能相");
|
||||
}
|
||||
if (edgeType === "sibling") {
|
||||
throw new Error("同胞关系由共享亲本自动推断,请通过 parent 关系维护");
|
||||
@@ -560,7 +560,7 @@ export async function upsertPedigreeEdge(payload: PedigreeEdgeFormState, origina
|
||||
export async function removePedigreeEdge(edgeId: string): Promise<void> {
|
||||
const [edgeType, thisNodeId, connectedNodeId] = edgeId.split(":");
|
||||
if (edgeType !== "parent" || !thisNodeId || !connectedNodeId) {
|
||||
throw new Error("仅支持删除 parent 关系");
|
||||
throw new Error("仅支持删<EFBFBD>?parent 关系");
|
||||
}
|
||||
|
||||
const nodes = await fetchPedigreeRowsWithRelations();
|
||||
|
||||
@@ -118,9 +118,9 @@ async function fetchSnapshotFromNetwork(): Promise<CrossPedigreeSnapshot> {
|
||||
const [programs, germplasm, crossingProjects, plannedCrosses, actualCrosses, observationUnits] = await Promise.all([
|
||||
loadProgramOptions(),
|
||||
loadGermplasmOptions(),
|
||||
request<BrapiListResponse<CrossingProject>>("/brapi/v2/crossingprojects?page=0&pageSize=1000"),
|
||||
request<BrapiListResponse<PlannedCross>>("/brapi/v2/plannedcrosses?page=0&pageSize=1000"),
|
||||
request<BrapiListResponse<Cross>>("/brapi/v2/crosses?page=0&pageSize=1000"),
|
||||
request<BrapiListResponse<CrossingProject>>("/brapi/v2/crossingprojects?page=0&pageSize=10"),
|
||||
request<BrapiListResponse<PlannedCross>>("/brapi/v2/plannedcrosses?page=0&pageSize=10"),
|
||||
request<BrapiListResponse<Cross>>("/brapi/v2/crosses?page=0&pageSize=10"),
|
||||
loadObservationUnitOptions().catch(() => [] as SelectOption[]),
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user