get_task_reports_smart
Retrieve task reports for GS cleaning robots by automatically selecting the appropriate API based on robot series, with filtering by time range and pagination.
Instructions
智能获取任务报告。
自动根据机器人系列选择M-line或S-line任务报告API。
Args:
serial_number: 机器人序列号
page: 页码
page_size: 每页大小
start_time_utc_floor: 开始时间过滤
start_time_utc_upper: 结束时间过滤
Returns:
任务报告数据字典
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serial_number | Yes | ||
| page | No | ||
| page_size | No | ||
| start_time_utc_floor | No | ||
| start_time_utc_upper | No |
Implementation Reference
- Core handler function that implements the smart routing logic for task reports: detects robot series from serial_number prefix and calls the appropriate MCP method (list_robot_task_reports_s for S-line or list_robot_task_reports for M-line/default). Adds metadata like api_version and detected_series.async def get_task_reports_smart(self, serial_number: str, **kwargs) -> Dict[str, Any]: """智能获取任务报告。 自动根据机器人序列号前缀选择M-line或S-line任务报告API。 """ # 基于序列号前缀判断机器人系列 detected_series = self._determine_robot_series_from_sn(serial_number) if self.is_s_line_robot(detected_series): # S-line 机器人使用专用任务报告API result = await self.mcp.list_robot_task_reports_s(serial_number, **kwargs) result["api_version"] = "S-line API" result["detected_series"] = detected_series return result else: # M-line 机器人或未知类型使用默认任务报告API result = await self.mcp.list_robot_task_reports(serial_number, **kwargs) result["api_version"] = "M-line/Default API" result["detected_series"] = detected_series return result
- src/gs_openapi/main.py:317-340 (registration)MCP tool registration using @mcp.tool() decorator. Defines input schema via parameters and docstring. Acts as a thin wrapper that prepares kwargs and delegates to the router's handler.@mcp.tool() async def get_task_reports_smart(serial_number: str, page: int = 1, page_size: int = 10, start_time_utc_floor: str = None, start_time_utc_upper: str = None): """智能获取任务报告。 自动根据机器人系列选择M-line或S-line任务报告API。 Args: serial_number: 机器人序列号 page: 页码 page_size: 每页大小 start_time_utc_floor: 开始时间过滤 start_time_utc_upper: 结束时间过滤 Returns: 任务报告数据字典 """ kwargs = {"page": page, "page_size": page_size} if start_time_utc_floor: kwargs["start_time_utc_floor"] = start_time_utc_floor if start_time_utc_upper: kwargs["start_time_utc_upper"] = start_time_utc_upper return await router.get_task_reports_smart(serial_number, **kwargs)
- Helper method that determines the robot series (e.g., '40', '50', '75', 'S', 'SW') from the serial number prefix using the ROBOT_SERIES_MAPPING. Critical for smart routing decisions.def _determine_robot_series_from_sn(self, serial_number: str) -> str: """根据序列号前缀判断机器人系列。 Args: serial_number: 机器人序列号 Returns: 机器人系列代码 (40, 50, 75, S, SW) 或 "unknown" """ if len(serial_number) < 5: return "unknown" prefix = serial_number[:5] return self.ROBOT_SERIES_MAPPING.get(prefix, "unknown")
- Static mapping dictionary of robot serial number prefixes to series codes, used by _determine_robot_series_from_sn to classify robots for API routing.ROBOT_SERIES_MAPPING = { # M-line 机器人 "GS100": "75", # 75系列 "GS400": "75", # 75系列 (新发现) "GS500": "75", # 75系列 "GS301": "50", # 50系列 "GS401": "50", # 50系列 "GS501": "50", # 50系列 (新发现) "GS442": "40", # 40系列 # S-line 机器人 "GS438": "S", # S系列 "GS408": "S", # S系列 "GS43C": "SW", # SW系列 }
- Helper method to check if a robot series code corresponds to S-line robots (uses V2/S-specific APIs).def is_s_line_robot(self, model_family_code: str) -> bool: """判断是否为S-line机器人。""" return model_family_code in ["S", "SW"]