Spaces:
Sleeping
Sleeping
File size: 3,279 Bytes
f6213fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | //! Browser preview structs embedded in `Plan.view_state`.
//!
//! These values are derived from the domain plan before transport. They let the
//! frontend render route summaries and timelines without duplicating every
//! scoring rule.
use serde::{Deserialize, Serialize};
/// Chooses whether routing uses fast straight lines or real road-network data.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RoutingMode {
StraightLine,
#[default]
RoadNetwork,
}
/// Selects which timeline rail the browser shows.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum TimelineView {
#[default]
ByVehicle,
ByDelivery,
}
/// UI-only state that travels with the plan between browser and backend.
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlanViewState {
#[serde(default)]
pub timeline_view: TimelineView,
pub selected_vehicle_id: Option<usize>,
pub selected_delivery_id: Option<usize>,
#[serde(default)]
pub preview: Option<PlanPreview>,
}
/// Aggregate route and score preview for the full plan.
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlanPreview {
pub hard_score: i64,
pub soft_score: i64,
pub unassigned_delivery_ids: Vec<usize>,
pub vehicles: Vec<VehiclePreview>,
pub deliveries: Vec<DeliveryPreview>,
}
/// Per-vehicle route summary used by cards, lists, and timelines.
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VehiclePreview {
pub vehicle_id: usize,
pub vehicle_name: String,
pub total_demand: i32,
pub capacity_overage: i32,
pub stop_count: usize,
pub total_travel_seconds: i64,
pub total_wait_seconds: i64,
pub total_service_seconds: i64,
pub total_late_seconds: i64,
pub start_time: i64,
pub end_time: i64,
pub stops: Vec<VehiclePreviewStop>,
}
/// One delivery stop on a vehicle timeline.
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VehiclePreviewStop {
pub delivery_id: usize,
pub label: String,
pub kind: String,
pub sequence: usize,
pub demand: i32,
pub min_start_time: i64,
pub max_end_time: i64,
pub arrival_time: i64,
pub service_start_time: i64,
pub departure_time: i64,
pub travel_seconds_from_previous: i64,
pub wait_seconds: i64,
pub late_seconds: i64,
}
/// Per-delivery assignment summary used by data tables and timelines.
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeliveryPreview {
pub delivery_id: usize,
pub label: String,
pub kind: String,
pub demand: i32,
pub min_start_time: i64,
pub max_end_time: i64,
pub service_duration: i64,
pub assigned_vehicle_id: Option<usize>,
pub assigned_vehicle_name: Option<String>,
pub sequence: Option<usize>,
pub arrival_time: Option<i64>,
pub service_start_time: Option<i64>,
pub departure_time: Option<i64>,
pub late_seconds: Option<i64>,
}
|