什麼是已排定的工作?
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本節的說明文件說明如何使用 Google Maps Mobility 排程工作服務建立及使用排程工作。本教學課程假設您熟悉下列項目:
您要使用的 Task
資源可在 gRPC 和 REST 中使用。
在預定工作專用的 Fleet Engine 中,工作代表駕駛員活動,可為消費者執行預定運送或服務。您可以將工作指派給車輛停靠地點,以便車輛前往這些地點完成工作。
工作有兩種可能狀態:OPEN
或 CLOSED
。這些狀態會指出任務在系統中是否處於啟用狀態。當有效任務的行程有所變動時,您可以透過更新與任務相關聯的車輛停靠站 (ENROUTE 或 ARRIVED),向 Fleet Engine 回報這項變動。駕駛員完成工作並離開停靠站後,您可以從車輛的停靠站清單中移除該停靠站。如要進一步瞭解工作以及與停靠站和車輛的關係,請參閱「Fleet Engine 重點」中的「排定工作」。
工作生命週期
如要在 Fleet Engine 中追蹤每項工作,您必須先建立 Task
實體。請參閱 gRCP 或 REST 的相關參考資料。
下表說明在系統中建立的任務,以及在 Fleet Engine 中的生命週期階段的端對端流程範例。這項操作假設您已設定 Fleet Engine,並且有用於該任務的車輛,且已在駕駛員應用程式中啟用位置更新功能。請參閱「駕駛員 SDK:排定任務」。
1 |
建立工作。 |
在工作週期開始時,調度器或服務管理員會先建立提交工作或服務的資訊清單。接著,系統會使用 CreateTrip 建立工作實體,其中包含必要欄位,例如工作類型和地點。此時,它也可以提供其他設定,例如目標時間視窗、分享工作進度和自訂屬性。請參閱「建立運送工作」和相關指南。 |
2 |
排定工作。 |
當您排定運送工作時,會發出運送車輛更新要求,然後更新車輛實體,其中包含要前往的停靠站清單。您可以為每個停靠站指派一份工作清單,以便在停靠站時完成。
請參閱「更新運送車輛工作」。
|
3 |
更新工作進度。 |
將工作指派給接送站並在 Fleet Engine 中啟用後,系統會在車輛接近、抵達及完成停靠時,通知 Fleet Engine 車輛的進度。有了這項資訊,車隊引擎就能為車輛在行程期間和一整天內,提供最佳的路線和狀態更新。請參閱「更新車輛停靠狀態」。 |
4 |
分享行程。 |
車輛開始在送貨日進行主動導航時,您可以與相關利害關係人分享行程資訊。Fleet Engine 會透過下列方式,向有興趣的利害關係人提供工作詳細資料和車輛位置:
- 消費者的運送資訊。有了這項解決方案,消費者就能查看包裹狀態,以及您允許他們查看的車輛位置資訊。
請參閱消費者分享預定任務。
- 管理員專用的車輛狀態資訊。有了這項解決方案,車隊管理員就能以近乎即時的方式,查看車隊中送貨車輛的位置和停靠站。如果已知車輛的路線,地圖檢視區塊元件會在車輛沿著預測路徑移動時,為該車輛顯示動畫。
請參閱 JavaScript 車隊追蹤程式庫。
|
5 |
完成工作。 |
您可以透過下列方式在 Fleet Engine 中完成運送工作:
- 關閉工作:關閉出貨工作表示該工作已無效。
- 設定工作結果:工作關閉後,您可以指出工作是成功或失敗,以表示是否已完成提交。這是完成任務的重要一環,可在消費者體驗中顯示運送結果,並確保 Fleet Engine 服務的正確計費。
請注意,與運送車輛一樣,工作實體在 Fleet Engine 中會保持有效狀態 7 天,無論其狀態為何,過期後就會遭到移除。請參閱「完成工作」。 |
工作序列流程
下圖顯示工作生命週期的詳細流程。

後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eThis documentation outlines how to create and manage scheduled tasks, representing driver activities, within the Google Maps Mobility scheduled tasks service.\u003c/p\u003e\n"],["\u003cp\u003eTasks, which can be either OPEN or CLOSED, are assigned to vehicle stops, and their progress is updated as the vehicle travels to and completes these stops.\u003c/p\u003e\n"],["\u003cp\u003eThe lifecycle of a task involves creation, scheduling by assigning to a vehicle stop, updating progress, sharing journey details with stakeholders, and finalization by closing and setting the outcome.\u003c/p\u003e\n"],["\u003cp\u003eFleet Engine provides tools for consumers to track shipment status and for administrators to monitor fleet locations and progress in near real-time.\u003c/p\u003e\n"],["\u003cp\u003eTo successfully use this service, prior familiarity with Fleet Engine, vehicle basics for on-demand services, and task basics for scheduled tasks is assumed.\u003c/p\u003e\n"]]],[],null,["# What is a scheduled task?\n\nThe documentation in this section shows how to create and work with scheduled\ntasks using the Google Maps Mobility scheduled tasks service. It assumes\nfamiliarity with the following:\n\n- **Fleet Engine** : You should be familiar with Fleet Engine implementation details, request mechanisms, and security. For that, see [What is the Fleet\n Engine service?](/maps/documentation/mobility/fleet-engine/essentials) and the security topics in [Set up Fleet Engine](/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet).\n- **Vehicles basics** for on-demand services. See [Introduction to vehicles](/maps/documentation/mobility/fleet-engine/essentials/vehicles-intro).\n- **Task basics** for scheduled task services. See [Scheduled tasks](/maps/documentation/mobility/fleet-engine/essentials/tasks-intro)\n\nThe `Task` resource that you'll use is available in both [gRPC](/maps/documentation/mobility/fleet-engine/reference/tasks/rpc/maps.fleetengine.delivery.v1#task) and\n[REST](/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks).\n\nIn Fleet Engine for scheduled tasks, a task represents a driver activity that\nfulfills a scheduled shipment or service for your consumers. You assign tasks to\nvehicle stop locations where they are to be completed, and the vehicle travels\nto those stops.\n\nA task has two possible states, `OPEN` or `CLOSED`. These states indicate\nwhether the task is active or not in the system. As the journey evolves for an\nactive task, you report this to Fleet Engine by updating the vehicle stop\nassociated with the task, which is either ENROUTE or ARRIVED. Once the driver\ncompletes tasks and leaves the stop, you remove the stop from the list of stops\non the vehicle. For more about\ntasks and their relationship to stops and vehicles, see\n[Scheduled tasks](/maps/documentation/mobility/fleet-engine/essentials/tasks-intro#basic_task_fields) in **Fleet Engine essentials** .\n\nLife of a task\n--------------\n\nIn order to track each task in Fleet Engine, you must first create a `Task`\nentity. See either [gRCP](/maps/documentation/mobility/fleet-engine/reference/tasks/rpc/maps.fleetengine.delivery.v1#task) or [REST](/maps/documentation/mobility/fleet-engine/reference/tasks/rest/v1/providers.tasks) for reference.\n\nThe following table describes an example end-to-end flow of a task created in\nyour system and its lifecycle stages in Fleet Engine. It assumes you have set up\nFleet Engine and have a vehicle for the task, with location updates\nenabled in the driver app. See [Driver SDK: Scheduled tasks](/maps/documentation/mobility/driver-sdk/scheduled).\n\n|---|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1 | **Create tasks.** | At the beginning of the work cycle, the dispatcher or service administrator first creates a manifest for delivery tasks or services. From there, your system then creates the task entities using `CreateTrip` with required fields, such as the type of task and the location. It can also supply other configurations at this point, such as target time window, sharing task progress, and custom attributes. See [Create shipment tasks](/maps/documentation/mobility/fleet-engine/journeys/tasks/create-shipment-tasks) and the related guides. |\n| 2 | **Schedule tasks.** | When you schedule a task for delivery, you issue a delivery vehicle update request, which then updates the vehicle entity with a list of stops to travel. You assign each stop a list of tasks to be completed at the stop. See [Update delivery vehicle tasks](/maps/documentation/mobility/fleet-engine/journeys/tasks/update-tasks). |\n| 3 | **Update the task progress.** | Once the task is assigned to a delivery stop and active in Fleet Engine, your system notifies Fleet Engine about the vehicle progress as it approaches, arrives at, and completes the stop. With this information, Fleet Engine can best perform routing and status updates along the journey as well as throughout the day for the vehicle. See [Update vehicle stop status](/maps/documentation/mobility/fleet-engine/journeys/tasks/update-stops). |\n| 4 | **Share journeys.** | At the same time that the vehicle begins active navigation for the delivery day, you can share journey information with interested stakeholders. Fleet Engine makes both task details and vehicle location available to interested stakeholders in the following ways: - **Shipment information for consumers** . With this solution, consumers can see the status of their package along with the vehicle location information you permit them to view. See [Consumer sharing for scheduled tasks](/maps/documentation/mobility/journey-sharing/scheduled). - **Fleet status information for administrators** . With this solution, fleet administrators can visualize the locations of delivery vehicles and their stops in your fleets in near real time. If the route for a vehicle is known, the map view component animates that vehicle as it moves along its predicted path. See the [JavaScript Fleet Tracking library](/maps/documentation/mobility/operations/fleet-tracking). |\n| 5 | **Finalize the task.** | You finalize shipment tasks in Fleet engine in the following ways: - **Close the task**: Closing a shipment task indicates that that task is no longer active. - **Set the task outcome**: Once a task is closed, you indicate either a successful or failed task to indicate if the delivery took place or not. This is an important part of finalizing a task to show the delivery outcome in your consumer experience and to ensure correct billing for the Fleet Engine service. Keep in mind that, like delivery vehicles, task entities remain active within Fleet Engine for 7 days regardless of state, at which point they are removed. See [Finalize tasks](/maps/documentation/mobility/fleet-engine/journeys/tasks/finalize-tasks). |\n\nTask sequence flow\n------------------\n\nThe following diagram shows a detailed flow of a task lifecycle.\n\nWhat's next\n-----------\n\n- [Create shipment tasks](/maps/documentation/mobility/fleet-engine/journeys/tasks/create-shipment-tasks)"]]