지도 작동되게 했음
This commit is contained in:
parent
a75b615c3a
commit
a4f0681f76
|
|
@ -34,7 +34,7 @@ interface Vehicle {
|
||||||
driver: string;
|
driver: string;
|
||||||
lat: number;
|
lat: number;
|
||||||
lng: number;
|
lng: number;
|
||||||
status: "active" | "inactive" | "maintenance" | "warning";
|
status: "active" | "inactive" | "maintenance" | "warning" | "off";
|
||||||
speed: number;
|
speed: number;
|
||||||
destination: string;
|
destination: string;
|
||||||
}
|
}
|
||||||
|
|
@ -88,24 +88,45 @@ export default function VehicleMapOnlyWidget({ element, refreshInterval = 30000
|
||||||
const statusCol = element.chartConfig.statusColumn || "status";
|
const statusCol = element.chartConfig.statusColumn || "status";
|
||||||
|
|
||||||
// DB 데이터를 Vehicle 형식으로 변환
|
// DB 데이터를 Vehicle 형식으로 변환
|
||||||
const vehiclesFromDB: Vehicle[] = result.data.rows.map((row: any, index: number) => ({
|
console.log("🗺️ [VehicleMapOnlyWidget] 원본 데이터:", result.data.rows);
|
||||||
id: row.id || row.vehicle_number || `V${index + 1}`,
|
console.log("🗺️ [VehicleMapOnlyWidget] 컬럼 매핑:", { latCol, lngCol, labelCol, statusCol });
|
||||||
name: row[labelCol] || `차량 ${index + 1}`,
|
|
||||||
driver: row.driver_name || row.driver || "미배정",
|
const vehiclesFromDB: Vehicle[] = result.data.rows
|
||||||
lat: parseFloat(row[latCol]),
|
.map((row: any, index: number) => {
|
||||||
lng: parseFloat(row[lngCol]),
|
const lat = parseFloat(row[latCol]);
|
||||||
status:
|
const lng = parseFloat(row[lngCol]);
|
||||||
row[statusCol] === "warning"
|
|
||||||
? "warning"
|
console.log(`🗺️ [VehicleMapOnlyWidget] 차량 ${index + 1}:`, {
|
||||||
: row[statusCol] === "active"
|
id: row.id || row.vehicle_number,
|
||||||
? "active"
|
latRaw: row[latCol],
|
||||||
: row[statusCol] === "maintenance"
|
lngRaw: row[lngCol],
|
||||||
? "maintenance"
|
latParsed: lat,
|
||||||
: "inactive",
|
lngParsed: lng,
|
||||||
speed: parseFloat(row.speed) || 0,
|
status: row[statusCol],
|
||||||
destination: row.destination || "대기 중",
|
});
|
||||||
}));
|
|
||||||
|
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);
|
setVehicles(vehiclesFromDB);
|
||||||
setLastUpdate(new Date());
|
setLastUpdate(new Date());
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue