123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- import requests
- # --- test 获取token ---
- # url = 'http://10.10.61.229:9000/token/api'
- url = 'http://192.168.131.23:9000/token/api'
- data = {
- 'username': 'admin', # 用户名
- 'password': 'admin', # 密码
- }
- response = requests.post(url=url, json=data)
- code = response.json().get('code')
- token = response.headers.get('authorization')
- # --- test 2001 获取全部渣包车状态 ---
- url = 'http://192.168.131.23:9000/v5/api'
- data = {
- 'code': 2001, # 接口号
- }
- response = requests.post(url=url, json=data, headers={'authorization': token})
- print(response.json())
- """
- {
- 'code': 0,
- 'data': [
- {
- 'name': '3号车', # 车辆名称
- 'address': '192.168.131.180', # 车辆ip
- 'check_vehicle_direction': True, # 当前车头方向是否符合自动驾驶条件 True 符合 False 不符合(默认值)
- 'state': 2, # 车辆状态 1 离线(默认值) 2 在线空闲 3 人工驾驶中 4 远程驾驶中 5 自动驾驶中
- 'current_vehicle_direction': 9, # 当前车头方向类型 3 围栏方向 9 渣场方向 12 维修间方向 6 维修间正对方向 0 未知(默认值)
- 'current_vehicle_weight': 0, # 当前车辆负载重量
- 'uuid': '65faa9d5921aec72550fb32d' # 车辆标识
- },
- {
- 'name': '5号车',
- 'address': '192.168.131.xxx',
- 'check_vehicle_direction': False,
- 'current_vehicle_direction': 0,
- 'state': 1,
- 'current_vehicle_weight': 0,
- 'uuid': '65faa9d5921aec72550fb32e'
- }
- ]
- }
- """
- # --- 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 2101 新增渣包车接口 ---
- # url = 'http://10.10.61.229:9000/v5/api'
- # data = {
- # 'code': 2101, # 接口号
- # 'name': '3号车', # 车辆名称
- # 'address': '192.168.131.41', # 网络地址
- # }
- # 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': '3号车', # 车辆名称
- # 'address': '192.168.131.41', # 网络地址
- # }
- # 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())
|