diff --git a/crop-x-new/src/app/(app)/land-information/suitability/multiFactor/components/cropKnowledgeBase.ts b/crop-x-new/src/app/(app)/land-information/suitability/multiFactor/components/cropKnowledgeBase.ts
index 28efa0b..ee5d5b0 100644
--- a/crop-x-new/src/app/(app)/land-information/suitability/multiFactor/components/cropKnowledgeBase.ts
+++ b/crop-x-new/src/app/(app)/land-information/suitability/multiFactor/components/cropKnowledgeBase.ts
@@ -3,7 +3,7 @@
* 提供作物-环境适配数据和分析功能
*/
-import { Crop, CropRecommendation, FieldFactors, MatchDetail, RiskFactor } from './multiFactorTypes';
+import { Crop, CropRecommendation, FieldFactors, MatchDetail } from './multiFactorTypes';
// 作物知识库数据
export const cropKnowledgeBase: Crop[] = [
diff --git a/crop-x-new/src/app/(app)/land-information/suitability/recommend/components/CropRecommendations.tsx b/crop-x-new/src/app/(app)/land-information/suitability/recommend/components/CropRecommendations.tsx
index 695eae6..9488ffb 100644
--- a/crop-x-new/src/app/(app)/land-information/suitability/recommend/components/CropRecommendations.tsx
+++ b/crop-x-new/src/app/(app)/land-information/suitability/recommend/components/CropRecommendations.tsx
@@ -3,10 +3,68 @@
import { Card } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Leaf, AlertTriangle, ThermometerSun, Cloud, Sun } from 'lucide-react';
-import { CropRecommendationState, SuitabilityResult } from './cropRecommendReducer';
+import { SuitabilityResult } from './cropRecommendReducer';
+
+type RangeRequirement = { optimal: [number, number]; acceptable: [number, number]; };
+type SoilFactorKey = 'ph' | 'organicMatter' | 'soilDepth' | 'nitrogen' | 'phosphorus' | 'potassium' | 'drainage';
+type SoilRequirementMap = Record;
+
+type ClimateRequirement = {
+ temperature: RangeRequirement;
+ rainfall: RangeRequirement;
+ sunlight: RangeRequirement;
+};
+
+type YieldRange = {
+ high: [number, number];
+ medium: [number, number];
+ low: [number, number];
+};
+
+type RiskSeverity = 'low' | 'medium' | 'high';
+
+interface CropRiskFactor {
+ id: string;
+ name: string;
+ condition: string;
+ severity: RiskSeverity;
+ suggestion: string;
+}
+
+interface CropKnowledgeEntry {
+ id: string;
+ cropName: string;
+ category: string;
+ description: string;
+ growthCycle: { days: number; seasons: string[] };
+ soilRequirements: SoilRequirementMap;
+ climateRequirements: ClimateRequirement;
+ expectedYield: YieldRange;
+ riskFactors: CropRiskFactor[];
+}
+
+type MatchStatus = '??' | '???' | '??';
+
+interface MatchDetail {
+ factor: string;
+ value: number;
+ score: number;
+ status: MatchStatus;
+}
+
+interface RecommendationResult {
+ crop: CropKnowledgeEntry;
+ matchScore: number;
+ suitabilityLevel: '????' | '??' | '????' | '???';
+ matchDetails: MatchDetail[];
+ applicableRisks: CropRiskFactor[];
+ expectedYield: [number, number];
+}
+
+type FieldFactors = Record;
// 模拟作物知识库数据
-const cropKnowledgeBase = [
+const cropKnowledgeBase: CropKnowledgeEntry[] = [
{
id: 'wheat',
cropName: '小麦',
@@ -40,14 +98,14 @@ const cropKnowledgeBase = [
id: 'wheat-rust',
name: '锈病风险',
condition: '湿度过高、温度适宜',
- severity: 'medium' as const,
+ severity: 'medium',
suggestion: '选择抗病品种,合理密植,及时防治'
},
{
id: 'wheat-drought',
name: '干旱风险',
condition: '降雨量不足400mm',
- severity: 'high' as const,
+ severity: 'high',
suggestion: '加强灌溉设施建设,选择抗旱品种'
}
]
@@ -85,14 +143,14 @@ const cropKnowledgeBase = [
id: 'corn-borer',
name: '玉米螟',
condition: '温度适宜、湿度适中',
- severity: 'medium' as const,
+ severity: 'medium',
suggestion: '生物防治与化学防治结合,适时播种'
},
{
id: 'corn-drought',
name: '花期干旱',
condition: '开花期降雨不足',
- severity: 'high' as const,
+ severity: 'high',
suggestion: '保证花期灌溉,选择耐旱品种'
}
]
@@ -130,7 +188,7 @@ const cropKnowledgeBase = [
id: 'soybean-disease',
name: '病害风险',
condition: '高温高湿环境',
- severity: 'medium' as const,
+ severity: 'medium',
suggestion: '选择抗病品种,合理轮作,加强田间管理'
}
]
@@ -138,11 +196,10 @@ const cropKnowledgeBase = [
];
interface CropRecommendationsProps {
- state: CropRecommendationState;
currentResult: SuitabilityResult;
}
-export function CropRecommendations({ state, currentResult }: CropRecommendationsProps) {
+export function CropRecommendations({ currentResult }: CropRecommendationsProps) {
// 匹配作物推荐
const matchCropsForField = (fieldFactors: any) => {
return cropKnowledgeBase.map(crop => {
diff --git a/crop-x-new/src/app/(app)/land-information/suitability/recommend/components/cropRecommendReducer.tsx b/crop-x-new/src/app/(app)/land-information/suitability/recommend/components/cropRecommendReducer.tsx
index 12e7e1f..95542ba 100644
--- a/crop-x-new/src/app/(app)/land-information/suitability/recommend/components/cropRecommendReducer.tsx
+++ b/crop-x-new/src/app/(app)/land-information/suitability/recommend/components/cropRecommendReducer.tsx
@@ -1,7 +1,5 @@
'use client';
-import { useReducer } from 'react';
-import { toast } from 'sonner';
export interface EvaluationFactor {
id: string;
diff --git a/crop-x-new/src/app/(app)/land-information/suitability/recommend/page.tsx b/crop-x-new/src/app/(app)/land-information/suitability/recommend/page.tsx
index 21b6c4e..ad621e6 100644
--- a/crop-x-new/src/app/(app)/land-information/suitability/recommend/page.tsx
+++ b/crop-x-new/src/app/(app)/land-information/suitability/recommend/page.tsx
@@ -7,8 +7,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
import { BookOpen, Target } from 'lucide-react';
import {
cropRecommendReducer,
- initialState,
- SuitabilityResult
+ initialState
} from './components/cropRecommendReducer';
import { FieldEnvironmentOverview } from './components/FieldEnvironmentOverview';
import { CropRecommendations } from './components/CropRecommendations';
@@ -117,7 +116,7 @@ export default function CropPage() {
{/* 智能作物推荐 */}
-
+
{/* 知识库对话框 */}