""" 常用参数服务模块 提供获取各种常用参数数据的服务 """ from typing import Dict, Any, List, Optional import json import random from datetime import datetime from config.component_config import CommonParamType class CommonParamsService: """常用参数服务类""" def __init__(self): """初始化服务""" # 模拟数据,实际项目中应该从数据库或外部API获取 self.mock_data = { CommonParamType.ROBOT_ID: [ {"id": "robot-001", "name": "机器人1号"}, {"id": "robot-002", "name": "机器人2号"}, {"id": "robot-003", "name": "机器人3号"} ], CommonParamType.ROBOT_GROUP: [ {"id": "group-001", "name": "机器人组A"}, {"id": "group-002", "name": "机器人组B"}, {"id": "group-003", "name": "机器人组C"} ], CommonParamType.ROBOT_TAG: [ {"id": "tag-001", "name": "标签1"}, {"id": "tag-002", "name": "标签2"}, {"id": "tag-003", "name": "标签3"} ], CommonParamType.STORAGE_AREA_ID: [ {"id": "area-001", "name": "库区1"}, {"id": "area-002", "name": "库区2"}, {"id": "area-003", "name": "库区3"} ], CommonParamType.STORAGE_AREA: [ {"id": "area-001", "name": "库区1", "code": "A001"}, {"id": "area-002", "name": "库区2", "code": "A002"}, {"id": "area-003", "name": "库区3", "code": "A003"} ], CommonParamType.SITE: [ {"id": "site-001", "name": "站点1", "code": "S001"}, {"id": "site-002", "name": "站点2", "code": "S002"}, {"id": "site-003", "name": "站点3", "code": "S003"} ], CommonParamType.BIN_TASK: [ {"id": "bin-001", "name": "Bin任务1"}, {"id": "bin-002", "name": "Bin任务2"}, {"id": "bin-003", "name": "Bin任务3"} ], CommonParamType.WORKSTATION: [ {"id": "ws-001", "name": "工位1"}, {"id": "ws-002", "name": "工位2"}, {"id": "ws-003", "name": "工位3"} ], CommonParamType.POST: [ {"id": "post-001", "name": "岗位1"}, {"id": "post-002", "name": "岗位2"}, {"id": "post-003", "name": "岗位3"} ], CommonParamType.USER: [ {"id": "user-001", "name": "用户1"}, {"id": "user-002", "name": "用户2"}, {"id": "user-003", "name": "用户3"} ], CommonParamType.CACHE: [ {"key": "cache-001", "value": "缓存值1"}, {"key": "cache-002", "value": "缓存值2"}, {"key": "cache-003", "value": "缓存值3"} ], CommonParamType.BUILT_IN_FUNCTION: [ {"name": "getCurrentTime", "description": "获取当前时间"}, {"name": "generateUUID", "description": "生成UUID"}, {"name": "formatDate", "description": "格式化日期"} ] } def get_param_data(self, param_type: str) -> List[Dict[str, Any]]: """ 获取指定类型的常用参数数据 Args: param_type: 参数类型 Returns: 参数数据列表 """ # 实际项目中,应该根据param_type调用相应的API或查询数据库 # 这里使用模拟数据 return self.mock_data.get(param_type, [])