Merge pull request 'lhj' (#237) from lhj into main

Reviewed-on: http://39.117.244.52:3000/kjs/ERP-node/pulls/237
This commit is contained in:
hjlee 2025-12-02 15:34:41 +09:00
commit 70c6da0527
1 changed files with 39 additions and 18 deletions

View File

@ -34,7 +34,7 @@ interface Vehicle {
driver: string;
lat: number;
lng: number;
status: "active" | "inactive" | "maintenance" | "warning";
status: "active" | "inactive" | "maintenance" | "warning" | "off";
speed: number;
destination: string;
}
@ -88,24 +88,45 @@ export default function VehicleMapOnlyWidget({ element, refreshInterval = 30000
const statusCol = element.chartConfig.statusColumn || "status";
// DB 데이터를 Vehicle 형식으로 변환
const vehiclesFromDB: Vehicle[] = result.data.rows.map((row: any, index: number) => ({
id: row.id || row.vehicle_number || `V${index + 1}`,
name: row[labelCol] || `차량 ${index + 1}`,
driver: row.driver_name || row.driver || "미배정",
lat: parseFloat(row[latCol]),
lng: parseFloat(row[lngCol]),
status:
row[statusCol] === "warning"
? "warning"
: row[statusCol] === "active"
? "active"
: row[statusCol] === "maintenance"
? "maintenance"
: "inactive",
speed: parseFloat(row.speed) || 0,
destination: row.destination || "대기 중",
}));
console.log("🗺️ [VehicleMapOnlyWidget] 원본 데이터:", result.data.rows);
console.log("🗺️ [VehicleMapOnlyWidget] 컬럼 매핑:", { latCol, lngCol, labelCol, statusCol });
const vehiclesFromDB: Vehicle[] = result.data.rows
.map((row: any, index: number) => {
const lat = parseFloat(row[latCol]);
const lng = parseFloat(row[lngCol]);
console.log(`🗺️ [VehicleMapOnlyWidget] 차량 ${index + 1}:`, {
id: row.id || row.vehicle_number,
latRaw: row[latCol],
lngRaw: row[lngCol],
latParsed: lat,
lngParsed: lng,
status: row[statusCol],
});
return {
id: row.id || row.vehicle_number || `V${index + 1}`,
name: row[labelCol] || `차량 ${index + 1}`,
driver: row.driver_name || row.driver || "미배정",
lat,
lng,
status:
row[statusCol] === "warning"
? "warning"
: row[statusCol] === "active"
? "active"
: row[statusCol] === "maintenance"
? "maintenance"
: "inactive",
speed: parseFloat(row.speed) || 0,
destination: row.destination || "대기 중",
};
})
// 유효한 위도/경도가 있는 차량만 필터링
.filter((v: Vehicle) => !isNaN(v.lat) && !isNaN(v.lng) && v.lat !== 0 && v.lng !== 0);
console.log("🗺️ [VehicleMapOnlyWidget] 유효한 차량 수:", vehiclesFromDB.length);
setVehicles(vehiclesFromDB);
setLastUpdate(new Date());
setIsLoading(false);