diff --git a/src/api/aiAnalysis.ts b/src/api/aiAnalysis.ts
index 2b182da..5c5367e 100644
--- a/src/api/aiAnalysis.ts
+++ b/src/api/aiAnalysis.ts
@@ -1,15 +1,15 @@
import request from '../request';
// 检测服务 Base URL
-const DETECT_BASE = 'http://50.50.50.117:10101';
+const DETECT_BASE = 'http://47.100.102.7:10101';
// 热成像分割服务 Base URL
-const SEGMENT_BASE = 'http://50.50.50.117:10102';
+const SEGMENT_BASE = 'http://47.100.102.7:10102';
/**
* 获取检测模型列表
*/
export function getDetectModels() {
- return fetch(`${DETECT_BASE}/api/v1/detect/models`).then(res => res.json());
+ return fetch(`${DETECT_BASE}/api/v1/detect/models`).then(res => res.json());
}
/**
@@ -17,24 +17,24 @@ export function getDetectModels() {
* @param formData 包含 files, inputType, modelAlias, conf, iou, imgsz, device, maxDet, vidStride
*/
export function submitDetectJob(formData: FormData) {
- return fetch(`${DETECT_BASE}/api/v1/detect/jobs`, {
- method: 'POST',
- body: formData
- }).then(res => res.json());
+ return fetch(`${DETECT_BASE}/api/v1/detect/jobs`, {
+ method: 'POST',
+ body: formData
+ }).then(res => res.json());
}
/**
* 查询检测任务状态
*/
export function getDetectJobStatus(jobId: string) {
- return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}`).then(res => res.json());
+ return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}`).then(res => res.json());
}
/**
* 查询检测结果
*/
export function getDetectJobResult(jobId: string) {
- return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}/result`).then(res => res.json());
+ return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}/result`).then(res => res.json());
}
/**
@@ -42,15 +42,15 @@ export function getDetectJobResult(jobId: string) {
* @param formData 包含 thermal_file, array_mask_file, panel_geojson_file, threshold_c, min_area_px, max_regions, open_k, close_k, shrink_in, include_panel_segments
*/
export function submitSegmentationAnalyze(formData: FormData) {
- return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyze`, {
- method: 'POST',
- body: formData
- }).then(res => res.json());
+ return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyze`, {
+ method: 'POST',
+ body: formData
+ }).then(res => res.json());
}
/**
* 获取热成像分析报告历史
*/
export function getSegmentationHistory() {
- return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyses/report`).then(res => res.json());
+ return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyses/report`).then(res => res.json());
}
diff --git a/src/pages/Agri.jsx b/src/pages/Agri.jsx
index f48fef8..6e1f7ec 100644
--- a/src/pages/Agri.jsx
+++ b/src/pages/Agri.jsx
@@ -66,6 +66,8 @@ export default function Agri() {
speedPreset: 'speed'
});
const [detectFiles, setDetectFiles] = useState([]);
+ const [selectedHotspot, setSelectedHotspot] = useState(null);
+
const [detectJobId, setDetectJobId] = useState(null);
const [detectStatus, setDetectStatus] = useState(null);
const [detectResult, setDetectResult] = useState(null);
@@ -119,6 +121,7 @@ export default function Agri() {
const formData = new FormData();
detectFiles.forEach(file => {
+ console.log(file, "dsdsvc")
formData.append('files', file.originFileObj);
});
formData.append('inputType', detectForm.inputType);
@@ -440,10 +443,12 @@ export default function Agri() {
setDetectFiles(info.fileList)}
+ onChange={info => {
+ setDetectFiles(info.fileList.slice(-1));
+ }}
beforeUpload={() => false}
+ limit={1}
style={{ background: '#fafafa', borderRadius: 8 }}
>
@@ -560,10 +565,100 @@ export default function Agri() {
);
- // 渲染结果展示
- const renderResults = () => {
- const result = activeAlgo === 'detect' ? detectResult : segResult;
- const inputFiles = activeAlgo === 'detect' ? detectFiles : (thermalFile ? [thermalFile] : []);
+ // 1. 目标检测的结果布局(第一张图的样式:三列)
+ const renderDetectResultLayout = () => {
+ const inputFile = detectFiles[0];
+ const hasResult = !!detectResult;
+
+ return (
+ 结果展示}
+ bordered={false}
+ style={{ marginTop: 12, borderRadius: 8 }}
+ bodyStyle={{ padding: '12px' }}
+ >
+
+ 原始预览、结果图与完整 JSON 同屏查看
+
+
+ {/* 输入预览 */}
+
+
+
+ {inputFile && (
+ detectForm.inputType === 'image' ? (
+
})
+ ) : (
+
+ )
+ )}
+
+
+
+
+ {/* 结果图/视频 */}
+
+
+
+
+ {hasResult ? (
+ detectForm.inputType === 'image' ? (
+

+ ) : (
+
+ )
+ ) : (
+
任务完成后显示结果
+ )}
+
+
+
+
+ {/* 结果JSON */}
+
+
+
+ {hasResult ? (
+
{JSON.stringify(detectResult, null, 2)}
+ ) : (
+
暂无结果
+ )}
+
+
+
+
+
+ );
+ };
+
+ // 2. 热成像分割的结果布局(第二张图的样式:两列)
+ // 2. 热成像分割的结果布局(第二张图的样式:两列 + 热点交互)
+ const renderSegResultLayout = () => {
+ const hasResult = !!segResult;
+ const inputFile = thermalFile;
+ const hotspots = segResult?.hotspots || [];
+ const panels = segResult?.panel_overview || [];
+
+ // 选中的点位详情
+ const selectedPoint = selectedHotspot
+ ? hotspots.find(h => h.hotspot_id === selectedHotspot)
+ : null;
return (
- {activeAlgo === 'segmentation' && segResult && (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- )}
+ {/* 顶部统计卡片 */}
+
+ 热成像交互分析视图
+ 点击热点或面板查看温度、块号、GPS 与像素溯源信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- {result ? (
- activeAlgo === 'detect' ? (
- detectForm.inputType === 'image' ? (
-

- ) : (
-
- )
- ) : (
-

- )
- ) : (
-
- 等待上传或调用服务器样例后显示结果图} image={Empty.PRESENTED_IMAGE_SIMPLE} />
-
+ {/* 左侧:结果图 + 热点标记 */}
+
+
+ {/*{inputFile && (
+

+ )}*/}
+ {!inputFile && (
+
请上传热成像文件} image={Empty.PRESENTED_IMAGE_SIMPLE} />
)}
+
+ {/* 热点标记点 */}
+ {hasResult && hotspots.map(hotspot => {
+ // 计算图片缩放比例,把原始坐标转为百分比位置
+ const scaleX = 100 / (segResult.image?.source_width || 4000);
+ const scaleY = 100 / (segResult.image?.source_height || 3000);
+ const left = hotspot.peak_x * scaleX;
+ const top = hotspot.peak_y * scaleY;
+
+ const isSelected = selectedHotspot === hotspot.hotspot_id;
+
+ return (
+ setSelectedHotspot(hotspot.hotspot_id)}
+ style={{
+ position: 'absolute',
+ left: `${left}%`,
+ top: `${top}%`,
+ transform: 'translate(-50%, -50%)',
+ width: isSelected ? 36 : 28,
+ height: isSelected ? 36 : 28,
+ borderRadius: '50%',
+ background: isSelected ? '#ff4d4f' : '#fa8c16',
+ color: '#fff',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ fontSize: 12,
+ fontWeight: 'bold',
+ cursor: 'pointer',
+ boxShadow: isSelected ? '0 0 0 4px rgba(255,77,79,0.4)' : '0 2px 8px rgba(0,0,0,0.3)',
+ border: '2px solid white',
+ transition: 'all 0.2s'
+ }}
+ >
+ {hotspot.hotspot_id}
+
+ );
+ })}
-
分析结果视图
-
-
-
-
点位详情
- {activeAlgo === 'segmentation' && segResult ? (
-
-
-
热点 GPS 样例
-
{segResult.hotspots?.[0]?.gps?.text || '暂无 GPS 信息'}
-
-
-
热点/面板列表
-
- {segResult.panel_overview?.slice(0, 10).map((p, i) => (
-
- 面板 #{i + 1}: {p.gps_text}
+
+ {/* 右侧:点位详情 + 列表 */}
+
+
请选择热点或面板}
+ style={{ height: 400 }}
+ bodyStyle={{ height: 350 }}
+ >
+ {/* 总容器:垂直布局,占满卡片内容区 */}
+
+
+ {/* --------------- 上半部分:点位详情 50% --------------- */}
+
+ {selectedPoint ? (
+
+
+
+ 热点 {selectedPoint.hotspot_id}
+ 热点
+
+
+
+ {[
+ { label: '温度', value: `${selectedPoint.peak_temp_c}℃` },
+ { label: '块号', value: selectedPoint.panel_id || '-' },
+ { label: 'GPS', value: selectedPoint.gps?.text || '-' },
+ { label: '原图像素', value: `${selectedPoint.peak_x}, ${selectedPoint.peak_y}` },
+ { label: '叠加图像素', value: `${selectedPoint.peak_x}, ${selectedPoint.peak_y}` },
+ { label: '面积', value: `${selectedPoint.area_px} px` }
+ ].map((item, i) => (
+
+ {item.label}
+ {item.value}
))}
-
- ) : (
-
- )}
+ ) : (
+
+ 等待分割结果,完成后可点击热点/面板查看详情
+
+ )}
+
+
+ {/* 分割线 */}
+
+
+ {/* --------------- 下半部分:热点/面板列表 50% --------------- */}
+
+
热点/面板列表
+ {panels.map((p, i) => (
+
{
+ const matchHotspot = hotspots.find(h => h.hotspot_id === i + 1);
+ if (matchHotspot) setSelectedHotspot(matchHotspot.hotspot_id);
+ }}
+ style={{
+ display: 'flex',
+ justifyContent: 'space-between',
+ padding: '8px 12px',
+ borderRadius: 4,
+ marginBottom: 4,
+ background: selectedHotspot === i + 1 ? '#e6f4ff' : '#fafafa',
+ cursor: 'pointer',
+ fontSize: 12
+ }}
+ >
+ {p.label || `面板 #${i + 1}`}
+ {p.peak_temp_c}℃
+
+ ))}
+
+
-
-
-
结果 JSON
- {result ? (
-
{JSON.stringify(result, null, 2)}
- ) :
}
-
-
-
详细数据
+
);
};
+ // 主渲染结果方法:根据算法选择不同布局
+ const renderResults = () => {
+ if (activeAlgo === 'detect') {
+ return renderDetectResultLayout();
+ } else {
+ return renderSegResultLayout();
+ }
+ };
return (
@@ -681,11 +955,9 @@ export default function Agri() {
算法分析中心
-
{renderStats()}
-
{/* 左侧:算法列表 */}