什么是计划任务?
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本部分的文档介绍了如何使用 Google 地图移动安排的任务服务创建和处理安排的任务。该文档假定您熟悉以下内容:
您将使用的 Task
资源同时支持 gRPC 和 REST。
在 Fleet Engine 的安排的任务中,任务表示为您的客户执行安排的运输或服务的驾驶员活动。您可以将任务分配给车辆停靠点(即任务完成地点),车辆会前往这些停靠点。
任务有两种可能的状态,即 OPEN
或 CLOSED
。这些状态表示任务在系统中是否处于活动状态。随着正在执行的任务的行程不断变化,您可以通过更新与任务关联的车辆停止状态(“正在行驶”或“已到达”)将此信息报告给车队引擎。当司机完成任务并离开相应经停点后,您可以从车辆上的经停点列表中移除该经停点。如需详细了解任务及其与经停点和车辆的关系,请参阅车队引擎基础知识中的安排的任务。
任务生命周期
如需跟踪 Fleet Engine 中的每个任务,您必须先创建一个 Task
实体。如需查看参考信息,请参阅 gRCP 或 REST。
下表介绍了在系统中创建的任务的端到端流程示例及其在车队引擎中的生命周期阶段。该示例假定您已设置车队引擎,并拥有用于执行任务的车辆,并且已在驾驶员应用中启用位置信息更新。请参阅Driver SDK:安排的任务。
1 |
创建任务。 |
在工作周期开始时,调度程序或服务管理员首先为提交任务或服务创建清单。然后,系统使用包含所需字段(例如任务类型和位置)的 CreateTrip 创建任务实体。此时,它还可以提供其他配置,例如目标时间范围、共享任务进度和自定义属性。请参阅创建发货任务和相关指南。 |
2 |
安排任务。 |
安排配送任务时,您会发出配送车辆更新请求,该请求会使用要经过的停靠点列表更新车辆实体。您可以为每个经停点分配要在该经停点完成的任务列表。
请参阅更新配送车辆任务。
|
3 |
更新任务进度。 |
将任务分配给送货点并在 Fleet Engine 中启用后,您的系统会在车辆接近、到达和完成相应送货点时通知 Fleet Engine 车辆的进度。有了这些信息,车队引擎便可针对车辆在行程期间以及全天内的状态,最妥善地执行路线规划和状态更新。请参阅更新车辆停止状态。
|
4 |
分享行程。 |
在车辆开始当天配送的导航时,您可以与感兴趣的利益相关方分享行程信息。Fleet Engine 会通过以下方式向感兴趣的利益相关方提供任务详情和车辆位置信息:
- 面向消费者的配送信息。借助此解决方案,消费者可以查看其包裹的状态以及您允许他们查看的车辆位置信息。
请参阅安排的任务的消费者共享。
- 面向管理员的车队状态信息。借助此解决方案,车队管理员可以近乎实时地直观了解车队中配送车辆的位置和其停靠点。
如果已知车辆的路线,地图视图组件会在车辆沿预测路径移动时为其添加动画效果。
请参阅 JavaScript 车队跟踪库。
|
5 |
最终确定任务。 |
您可以通过以下方式在车队引擎中最终确定运输任务:
- 关闭任务:关闭发货任务表示该任务已不再处于活跃状态。
- 设置任务结果:任务关闭后,您可以指明任务是成功还是失败,以指明是否已进行提交。这是完成任务的重要环节,可在消费者体验中显示传送结果,并确保正确结算车队引擎服务费用。
请注意,与配送车辆一样,无论任务实体处于何种状态,都会在车队引擎中保持活跃状态 7 天,之后便会被移除。
请参阅最终确定任务。
|
任务序列流
下图显示了任务生命周期的详细流程。

后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):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)"]]