# --- test 获取token --- service_url = 'http://10.10.61.229:9000' url = f'{service_url}/token/api' data = { 'username': 'admin', 'password': 'admin', } response = requests.post(url=url, json=data) print(response.headers) """ { 'date': 'Thu, 04 Jan 2024 07:19:58 GMT', 'server': 'uvicorn', # 登录token 'authorization': 'eyJhbGciOiJIUzUxMiIsImlhdCI6MTcwNDM1Mjc5OCwiZXhwIjoxNzA0NDM5MTk4fQ.eyJpZCI6IjY1NGUzNmI0NjBmZGE0M2UzOTI2YzNmYiIsInVzZXJuYW1lIjoiYWRtaW4iLCJwYXNzd29yZCI6InBia2RmMjpzaGEyNTY6MTUwMDAwJGxEN1duR0hxJGUyNjhhNzgxOTFhYjdiNDE2ZDcxZjE1MDkxNzJjZWVkZWI3ZTNmNTM1ZGY0MGQ5NmQ4MzZlYmRjNTFmZGRmMzkifQ.IGi0lXezecP5AEjxgQ4lzQ5jyeYwDLoGmD7n29Q_1X6faSo4EKj4Q8A89BiAKBhjGAiNe7FSBFjmqhoZEXacUg', 'content-length': '107', 'content-type': 'application/json' } """ print(response.json()) """ { 'code': 0 # 错误码 {0: 无异常} 'message': 'authorization passed.', 'uid': '654e36b460fda43e3926c3fb', # 用户id 'role_name': '超级管理员', } """ # --- test 2001 获取全部渣包车状态 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 2001, # 接口号 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': [ { 'uuid': 'aabbssff', # 渣包车唯一标识 'name': '6号车', # 别称 'status': 1 # 状态 # 1:离线 2:在线空闲 3: 人工驾驶中 4: 远程驾驶中 5: 自动驾驶中 } ] } """ # --- test 2002 指定渣包车点火操作接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 2002, # 接口号 'uuid': 'aassfafe', # 渣包车唯一标识 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': 'aassfafe' } """ # --- test 2003 指定渣包车熄火操作接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 2003, # 接口号 'uuid': 'aassfafe', # 渣包车唯一标识 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': 'aassfafe' } """ # --- test 2004 指定渣包车建立远程操作权限(或是切换)接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 2004, # 接口号 'uuid': 'aassfafe', # 渣包车唯一标识 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': 'aassfafe' } """ # --- test 2005 开始作业接口(基于当前渣包车,选定作业内容) --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 2005, # 接口号 'uuid': 'aassfafe', # 渣包车唯一标识 'task_type': 'aassfafe', # 作业类型 # 1: 叉包 2: 翻包 3:放包 'task_plan': [ {'name': 'L20', 'x': '54', 'y': '211'}, {'name': 'CD01端转弯圆心', 'x': '54', 'y': '211'}, {'name': '#6倒渣口', 'x': '54', 'y': '211'}, ], # 路径规划 # name: 包位名称/倒渣口名称/转弯圆心点坐标 x: 坐标值 y: 坐标值 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': 'aassfafe' } """ # --- test 2101 新增渣包车接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 2101, # 接口号 'name': '3号车', # 别称 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': 'aassfafe' } """ # --- test 2102 修改渣包车接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 2102, # 接口号 'uuid': '659765411dd2f1fe6d346b3b', # 渣包车唯一标识 'name': '6号车', # 别称 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': { 'uuid': '659765411dd2f1fe6d346b3b', 'name': '6号车', 'update_at': 1704435941 } } """ # --- test 2103 删除渣包车接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 2103, # 接口号 'uuid': '659764dd6b8e37c3ce95d849', # 渣包车唯一标识 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) # --- test 3001 任务列表数据获取接口(分页) --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 3001, # 接口号 'page': 1, # 分页 'size': 10, # 每页条数 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': [ { 'uuid': '659765411dd2f1fe6d346b3b', # 任务id 'vehicle_uuid': '659765411dd2f1fe6d346b3b' # 任务车辆id } ], 'page': 1, 'size': 10, 'total': 1 # 总条数 } """ # --- test 3002 任务暂停接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 3002, # 接口号 'uuid': 'aassfafe', # 任务id } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': 'aassfafe' } """ # --- test 3003 任务取消接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 3003, # 接口号 'uuid': 'aassfafe', # 任务id } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': 'aassfafe' } """ # --- test 4001 获取全部渣包状态数据接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 4001, # 接口号 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': { '倒渣口-1': 1, '倒渣口-2': 1, '倒渣口-3': 1, '倒渣口-4': 1, '倒渣口-5': 1, '倒渣口-6': 1, '倒渣口-7': 1, '包位-A-1': 1, '包位-A-2': 1, '包位-A-3': 1, '包位-A-4': 1, '包位-A-5': 1, '包位-A-6': 1, '包位-A-7': 1, '包位-A-8': 1, '包位-A-9': 1, '包位-A-10': 1, '包位-A-11': 1, '包位-A-12': 1, '包位-A-13': 1, '包位-A-14': 1, '包位-A-15': 1, '包位-A-16': 1, '包位-A-17': 1, '包位-A-18': 1, '包位-A-19': 1, '包位-A-20': 1, '包位-A-21': 1, '包位-A-22': 1, '包位-A-23': 1, '包位-A-24': 1, '包位-A-25': 1, '包位-A-26': 1, '包位-A-27': 1, '包位-A-28': 1, '包位-A-29': 1, '包位-A-30': 1, '包位-A-31': 1, } } """ # --- test 5001 获取告警数据列表接口 --- url = 'http://10.10.61.229:9000/v5/api' data = { 'code': 5001, # 接口号 } response = requests.post(url=url, json=data, headers={'authorization': token}) print(response.json()) """ { 'code': 0, 'data': [ { 'message': '1号车油量低,请及时加油!', # 警告内容 'create_at': 1704435199 # 警告时间(时间戳) } ] } """