Files
bj_power/bj_power_mes/internal/processor/tool/helpers.go
T

20 lines
469 B
Go
Raw Normal View History

package tool
// extractWorkpieceType 从参数中提取工件类型 ID
func extractWorkpieceType(params map[string]any) int {
return extractIntParam(params, "workpieceType")
}
// extractIntParam 从参数 map 中提取 int 类型值,支持 int/float64 转换
func extractIntParam(params map[string]any, key string) int {
if v, ok := params[key]; ok {
if n, ok := v.(int); ok {
return n
}
if f, ok := v.(float64); ok {
return int(f)
}
}
return 0
}