저장 버튼을 누르기 전 저장 x
This commit is contained in:
@@ -153,18 +153,35 @@ export class YardLayoutService {
|
||||
`;
|
||||
|
||||
const pool = getPool();
|
||||
|
||||
// NaN 방지를 위한 안전한 변환 함수
|
||||
const safeParseInt = (
|
||||
value: any,
|
||||
defaultValue: number | null = null
|
||||
): number | null => {
|
||||
if (!value && value !== 0) return defaultValue;
|
||||
const parsed = parseInt(String(value), 10);
|
||||
return isNaN(parsed) ? defaultValue : parsed;
|
||||
};
|
||||
|
||||
const safeParseFloat = (value: any, defaultValue: number): number => {
|
||||
if (!value && value !== 0) return defaultValue;
|
||||
const parsed = parseFloat(String(value));
|
||||
return isNaN(parsed) ? defaultValue : parsed;
|
||||
};
|
||||
|
||||
const result = await pool.query(query, [
|
||||
layoutId,
|
||||
data.material_code || null,
|
||||
data.material_name || null,
|
||||
data.quantity ? parseInt(String(data.quantity), 10) : null,
|
||||
safeParseInt(data.quantity, null),
|
||||
data.unit || null,
|
||||
data.position_x ? parseFloat(String(data.position_x)) : 0,
|
||||
data.position_y ? parseFloat(String(data.position_y)) : 0,
|
||||
data.position_z ? parseFloat(String(data.position_z)) : 0,
|
||||
data.size_x ? parseFloat(String(data.size_x)) : 5,
|
||||
data.size_y ? parseFloat(String(data.size_y)) : 5,
|
||||
data.size_z ? parseFloat(String(data.size_z)) : 5,
|
||||
safeParseFloat(data.position_x, 0),
|
||||
safeParseFloat(data.position_y, 0),
|
||||
safeParseFloat(data.position_z, 0),
|
||||
safeParseFloat(data.size_x, 5),
|
||||
safeParseFloat(data.size_y, 5),
|
||||
safeParseFloat(data.size_z, 5),
|
||||
data.color || "#9ca3af", // 미설정 시 회색
|
||||
data.data_source_type || null,
|
||||
data.data_source_config ? JSON.stringify(data.data_source_config) : null,
|
||||
@@ -201,23 +218,31 @@ export class YardLayoutService {
|
||||
`;
|
||||
|
||||
const pool = getPool();
|
||||
|
||||
// NaN 방지를 위한 안전한 변환 함수
|
||||
const safeParseInt = (value: any): number | null => {
|
||||
if (value === null || value === undefined) return null;
|
||||
const parsed = parseInt(String(value), 10);
|
||||
return isNaN(parsed) ? null : parsed;
|
||||
};
|
||||
|
||||
const safeParseFloat = (value: any): number | null => {
|
||||
if (value === null || value === undefined) return null;
|
||||
const parsed = parseFloat(String(value));
|
||||
return isNaN(parsed) ? null : parsed;
|
||||
};
|
||||
|
||||
const result = await pool.query(query, [
|
||||
data.material_code !== undefined ? data.material_code : null,
|
||||
data.material_name !== undefined ? data.material_name : null,
|
||||
data.quantity !== undefined ? parseInt(String(data.quantity), 10) : null,
|
||||
data.quantity !== undefined ? safeParseInt(data.quantity) : null,
|
||||
data.unit !== undefined ? data.unit : null,
|
||||
data.position_x !== undefined
|
||||
? parseFloat(String(data.position_x))
|
||||
: null,
|
||||
data.position_y !== undefined
|
||||
? parseFloat(String(data.position_y))
|
||||
: null,
|
||||
data.position_z !== undefined
|
||||
? parseFloat(String(data.position_z))
|
||||
: null,
|
||||
data.size_x !== undefined ? parseFloat(String(data.size_x)) : null,
|
||||
data.size_y !== undefined ? parseFloat(String(data.size_y)) : null,
|
||||
data.size_z !== undefined ? parseFloat(String(data.size_z)) : null,
|
||||
data.position_x !== undefined ? safeParseFloat(data.position_x) : null,
|
||||
data.position_y !== undefined ? safeParseFloat(data.position_y) : null,
|
||||
data.position_z !== undefined ? safeParseFloat(data.position_z) : null,
|
||||
data.size_x !== undefined ? safeParseFloat(data.size_x) : null,
|
||||
data.size_y !== undefined ? safeParseFloat(data.size_y) : null,
|
||||
data.size_z !== undefined ? safeParseFloat(data.size_z) : null,
|
||||
data.color !== undefined ? data.color : null,
|
||||
data.data_source_type !== undefined ? data.data_source_type : null,
|
||||
data.data_source_config !== undefined
|
||||
|
||||
Reference in New Issue
Block a user