diff --git a/README.md b/README.md index 3290898..fdb3ff2 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ $body = @{ speed = 42 heading = 90 cargoName = "전자부품" + cargoQuantity = "36박스" cargoWeight = "1.2t" origin = "서울 상차지" destination = "평택 물류센터" diff --git a/apps/server/src/server.js b/apps/server/src/server.js index a45d2d8..c0d2e43 100644 --- a/apps/server/src/server.js +++ b/apps/server/src/server.js @@ -37,6 +37,7 @@ const SIMULATED_FLEET = [ token: "sim-token-01", vehicleType: "tractor-trailer", cargoName: "자동차 부품", + cargoQuantity: "24팔레트", cargoWeight: "18t", speedBase: 76, loopMs: 16 * 60 * 1000, @@ -54,6 +55,7 @@ const SIMULATED_FLEET = [ token: "sim-token-02", vehicleType: "container", cargoName: "수출 컨테이너", + cargoQuantity: "40피트 1대", cargoWeight: "22t", speedBase: 72, loopMs: 15 * 60 * 1000, @@ -71,6 +73,7 @@ const SIMULATED_FLEET = [ token: "sim-token-03", vehicleType: "cargo-truck", cargoName: "건축 자재", + cargoQuantity: "철근 320본", cargoWeight: "8t", speedBase: 68, loopMs: 13 * 60 * 1000, @@ -88,6 +91,7 @@ const SIMULATED_FLEET = [ token: "sim-token-04", vehicleType: "van", cargoName: "소형 택배", + cargoQuantity: "186박스", cargoWeight: "0.9t", speedBase: 54, loopMs: 9 * 60 * 1000, @@ -105,6 +109,7 @@ const SIMULATED_FLEET = [ token: "sim-token-05", vehicleType: "refrigerated", cargoName: "냉장 식품", + cargoQuantity: "72박스", cargoWeight: "3.5t", speedBase: 62, loopMs: 12 * 60 * 1000, @@ -122,6 +127,7 @@ const SIMULATED_FLEET = [ token: "sim-token-06", vehicleType: "wingbody", cargoName: "생활용품 팔레트", + cargoQuantity: "14팔레트", cargoWeight: "5t", speedBase: 66, loopMs: 11 * 60 * 1000, @@ -139,6 +145,7 @@ const SIMULATED_FLEET = [ token: "sim-token-07", vehicleType: "box-truck", cargoName: "전자제품", + cargoQuantity: "96박스", cargoWeight: "2.5t", speedBase: 61, loopMs: 10 * 60 * 1000, @@ -156,6 +163,7 @@ const SIMULATED_FLEET = [ token: "sim-token-08", vehicleType: "tractor-trailer", cargoName: "철강 코일", + cargoQuantity: "코일 5롤", cargoWeight: "20t", speedBase: 58, loopMs: 14 * 60 * 1000, @@ -173,6 +181,7 @@ const SIMULATED_FLEET = [ token: "sim-token-09", vehicleType: "van", cargoName: "호텔 린넨", + cargoQuantity: "38카트", cargoWeight: "0.7t", speedBase: 46, loopMs: 8 * 60 * 1000, @@ -190,6 +199,7 @@ const SIMULATED_FLEET = [ token: "sim-token-10", vehicleType: "cargo-truck", cargoName: "농산물", + cargoQuantity: "220상자", cargoWeight: "4.5t", speedBase: 57, loopMs: 12 * 60 * 1000, @@ -566,6 +576,7 @@ function createSimulatorLocationBody(vehicle, nowMs) { speed: Math.max(18, Math.round(vehicle.speedBase + speedWave)), heading: routeState.heading, cargoName: vehicle.cargoName, + cargoQuantity: vehicle.cargoQuantity, cargoWeight: vehicle.cargoWeight, origin: routeState.origin, destination: routeState.destination, @@ -736,6 +747,7 @@ function createLocationRecord(body, driver) { heading: optionalNumber(body.heading), batteryLevel: optionalNumber(body.batteryLevel), cargoName: optionalString(body.cargoName || body.cargoItem || body.cargo || body.itemName, 80), + cargoQuantity: optionalString(body.cargoQuantity || body.quantity || body.qty || body.count, 40), cargoWeight: optionalString(body.cargoWeight || body.weight, 40), origin: optionalString(body.origin || body.departure, 80), destination: optionalString(body.destination || body.arrival, 80), diff --git a/apps/web/public/app.js b/apps/web/public/app.js index da63aea..5371de9 100644 --- a/apps/web/public/app.js +++ b/apps/web/public/app.js @@ -304,6 +304,7 @@ async function postDemoLocation() { speed: 42, heading: Math.round((now / 1000) % 360), cargoName: "전자부품", + cargoQuantity: "36박스", cargoWeight: "1.2t", origin: "서울 상차지", destination: "평택 물류센터", @@ -859,7 +860,13 @@ function createPopupElement(location, status) { const cargo = document.createElement("div"); cargo.className = "popup-cargo"; - cargo.textContent = `화물: ${getCargoSummary(location)}`; + cargo.textContent = `제품: ${getCargoName(location) || "미등록"}`; + + const quantity = document.createElement("div"); + quantity.textContent = `수량: ${getCargoQuantity(location) || "미등록"}`; + + const weight = document.createElement("div"); + weight.textContent = `중량: ${getCargoWeight(location) || "미등록"}`; const destination = document.createElement("div"); destination.textContent = getRouteSummary(location); @@ -870,7 +877,7 @@ function createPopupElement(location, status) { const movement = document.createElement("div"); movement.textContent = `속도: ${formatSpeed(location.speed)}`; - container.append(title, driver, cargo, destination, movement, receivedAt); + container.append(title, driver, cargo, quantity, weight, destination, movement, receivedAt); return container; } @@ -974,9 +981,21 @@ function formatCoordinate(value) { } function getCargoSummary(location) { - const cargoName = firstString(location.cargoName, location.cargoItem, location.cargo, location.itemName); - const cargoWeight = firstString(location.cargoWeight, location.weight); - return [cargoName, cargoWeight].filter(Boolean).join(" · ") || "미등록"; + return [getCargoName(location), getCargoQuantity(location), getCargoWeight(location)] + .filter(Boolean) + .join(" · ") || "미등록"; +} + +function getCargoName(location) { + return firstString(location.cargoName, location.cargoItem, location.cargo, location.itemName); +} + +function getCargoQuantity(location) { + return firstString(location.cargoQuantity, location.quantity, location.qty, location.count); +} + +function getCargoWeight(location) { + return firstString(location.cargoWeight, location.weight); } function getRouteSummary(location) {