2025-07-30 09:13:52 +08:00
|
|
|
|
import http from '@/utils/http'
|
|
|
|
|
|
|
|
|
|
// 缺陷检测请求参数
|
|
|
|
|
export interface DefectDetectionRequest {
|
|
|
|
|
confThreshold: number
|
|
|
|
|
defectTypeList: string[]
|
|
|
|
|
imageId: string
|
|
|
|
|
modelId: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 手动添加缺陷请求参数
|
|
|
|
|
export interface ManualDefectAddRequest {
|
|
|
|
|
attachId: string
|
|
|
|
|
axial: number
|
|
|
|
|
chordwise: number
|
|
|
|
|
defectCode: string
|
|
|
|
|
defectLevel: string
|
|
|
|
|
defectName: string
|
|
|
|
|
defectPosition: string
|
|
|
|
|
defectType: string
|
|
|
|
|
description: string
|
|
|
|
|
detectionDate: string
|
|
|
|
|
labelInfo: string
|
|
|
|
|
markInfo: {
|
|
|
|
|
bbox: number[]
|
|
|
|
|
clsId: number
|
|
|
|
|
confidence: number
|
|
|
|
|
label: string
|
|
|
|
|
}
|
|
|
|
|
repairIdea: string
|
|
|
|
|
repairStatus: string
|
|
|
|
|
source: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 缺陷检测结果
|
|
|
|
|
export interface DefectDetectionResult {
|
|
|
|
|
attachId: string
|
|
|
|
|
attachPath: string
|
|
|
|
|
axial: number
|
|
|
|
|
chordwise: number
|
|
|
|
|
defectCode: string
|
|
|
|
|
defectId: string
|
|
|
|
|
defectLevel: string
|
|
|
|
|
defectLevelLabel: string
|
|
|
|
|
defectName: string
|
|
|
|
|
defectPosition: string
|
|
|
|
|
defectType: string
|
|
|
|
|
defectTypeLabel: string
|
|
|
|
|
description: string
|
|
|
|
|
detectionDate: string
|
|
|
|
|
imageId: string
|
|
|
|
|
labelInfo: string
|
|
|
|
|
markInfo: {
|
|
|
|
|
bbox: number[]
|
|
|
|
|
clsId: number
|
|
|
|
|
confidence: number
|
|
|
|
|
label: string
|
|
|
|
|
}
|
|
|
|
|
repairIdea: string
|
|
|
|
|
repairStatus: string
|
|
|
|
|
repairStatusLabel: string
|
|
|
|
|
source: string
|
|
|
|
|
sourceLabel: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// API响应结构
|
|
|
|
|
export interface DefectDetectionResponse {
|
|
|
|
|
code: number
|
|
|
|
|
data: DefectDetectionResult[]
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 手动添加缺陷响应结构
|
|
|
|
|
export interface ManualDefectAddResponse {
|
|
|
|
|
code: number
|
|
|
|
|
data: DefectDetectionResult
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @desc 单图自动标注缺陷 */
|
|
|
|
|
export const detectDefects = (params: DefectDetectionRequest) => {
|
|
|
|
|
return http.post<DefectDetectionResponse>('/defect/detect', params)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @desc 手动添加缺陷记录 */
|
2025-07-31 17:32:21 +08:00
|
|
|
|
export const addManualDefect = (params: ManualDefectAddRequest, imageId: string) => {
|
2025-07-30 09:13:52 +08:00
|
|
|
|
return http.post<ManualDefectAddResponse>(`/defect/${imageId}`, params)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 缺陷相关的其他接口
|
|
|
|
|
|
|
|
|
|
// 缺陷列表查询参数接口
|
|
|
|
|
export interface DefectListParams {
|
2025-07-31 17:32:21 +08:00
|
|
|
|
defectId?: string
|
|
|
|
|
defectLevel?: string
|
|
|
|
|
defectType?: string
|
|
|
|
|
keyword?: string
|
|
|
|
|
turbineId?: string
|
|
|
|
|
imageId?: string // 添加imageId参数,用于按图像筛选缺陷
|
2025-07-30 09:13:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @desc 获取缺陷列表 */
|
|
|
|
|
export const getDefectList = (params: DefectListParams) => {
|
|
|
|
|
return http.get<{
|
|
|
|
|
code: number
|
|
|
|
|
data: DefectDetectionResult[]
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
2025-07-31 17:32:21 +08:00
|
|
|
|
}>('/defect/list', params)
|
2025-07-30 09:13:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @desc 添加缺陷 */
|
|
|
|
|
export const addDefect = (params: Partial<DefectDetectionResult>) => {
|
|
|
|
|
return http.post<{
|
|
|
|
|
code: number
|
|
|
|
|
data: DefectDetectionResult
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
|
|
|
|
}>('/defect/add', params)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @desc 更新缺陷 */
|
|
|
|
|
export const updateDefect = (defectId: string, params: Partial<DefectDetectionResult>) => {
|
|
|
|
|
return http.put<{
|
|
|
|
|
code: number
|
|
|
|
|
data: DefectDetectionResult
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
|
|
|
|
}>(`/defect/${defectId}`, params)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @desc 删除缺陷 */
|
|
|
|
|
export const deleteDefect = (defectId: string) => {
|
|
|
|
|
return http.del<{
|
|
|
|
|
code: number
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
|
|
|
|
}>(`/defect/${defectId}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @desc 上传标注后的图片作为附件 */
|
|
|
|
|
export const uploadAnnotatedImage = (imageBlob: Blob, fileName: string) => {
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append('file', imageBlob, fileName)
|
2025-07-31 17:32:21 +08:00
|
|
|
|
|
2025-07-30 09:13:52 +08:00
|
|
|
|
return http.post<{
|
|
|
|
|
code: number
|
|
|
|
|
data: AttachInfoData
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
|
|
|
|
}>('/attach-info/defect_mark_pic', formData, {
|
|
|
|
|
headers: {
|
2025-07-31 17:32:21 +08:00
|
|
|
|
'Content-Type': 'multipart/form-data',
|
|
|
|
|
},
|
2025-07-30 09:13:52 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 附件信息数据类型
|
|
|
|
|
export interface AttachInfoData {
|
|
|
|
|
attachId: string
|
|
|
|
|
attachPath: string
|
|
|
|
|
fileName: string
|
|
|
|
|
fileSize: number
|
|
|
|
|
contentType: string
|
|
|
|
|
uploadTime: string
|
|
|
|
|
[key: string]: any
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 缺陷信息接口
|
|
|
|
|
export interface DefectInfo {
|
2025-07-31 17:32:21 +08:00
|
|
|
|
id: string
|
|
|
|
|
defectId?: string
|
|
|
|
|
defectName?: string
|
|
|
|
|
defectLevel?: string
|
|
|
|
|
defectType?: string
|
|
|
|
|
defectPosition?: string
|
|
|
|
|
detectionDate?: string
|
|
|
|
|
description?: string
|
|
|
|
|
repairStatus?: string
|
|
|
|
|
repairIdea?: string
|
|
|
|
|
labelInfo?: string
|
2025-07-30 09:13:52 +08:00
|
|
|
|
markInfo?: {
|
2025-07-31 17:32:21 +08:00
|
|
|
|
bbox?: number[]
|
|
|
|
|
clsId?: number
|
|
|
|
|
confidence?: number
|
|
|
|
|
label?: string
|
|
|
|
|
[key: string]: any
|
|
|
|
|
}
|
|
|
|
|
[key: string]: any
|
2025-07-30 09:13:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 缺陷等级类型
|
|
|
|
|
export interface DefectLevelType {
|
2025-07-31 17:32:21 +08:00
|
|
|
|
code: string
|
|
|
|
|
name: string
|
|
|
|
|
value: string
|
|
|
|
|
sort: number
|
|
|
|
|
description?: string
|
2025-07-30 09:13:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 缺陷类型
|
|
|
|
|
export interface DefectType {
|
2025-07-31 17:32:21 +08:00
|
|
|
|
code: string
|
|
|
|
|
name: string
|
|
|
|
|
value: string
|
|
|
|
|
sort: number
|
|
|
|
|
description?: string
|
2025-07-30 09:13:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取缺陷等级列表
|
|
|
|
|
export const getDefectLevels = () => {
|
|
|
|
|
return http.get<{
|
2025-07-31 17:32:21 +08:00
|
|
|
|
code: number
|
|
|
|
|
data: DefectLevelType[]
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
2025-07-30 09:13:52 +08:00
|
|
|
|
}>('/common/list/defect-level')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取缺陷类型列表
|
|
|
|
|
export const getDefectTypes = () => {
|
|
|
|
|
return http.get<{
|
2025-07-31 17:32:21 +08:00
|
|
|
|
code: number
|
|
|
|
|
data: DefectType[]
|
|
|
|
|
msg: string
|
|
|
|
|
status: number
|
|
|
|
|
success: boolean
|
2025-07-30 09:13:52 +08:00
|
|
|
|
}>('/common/list/defect-type')
|
2025-07-31 17:32:21 +08:00
|
|
|
|
}
|