123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- # --- 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 # 警告时间(时间戳)
- }
- ]
- }
- """
|