# --- test 获取token ---
# url = 'http://58.34.94.177:29101/v1/token'
url = 'http://127.0.0.1:9000/v1/token'
data = {
'username': 'admin', # 登录账户
'password': '123456', # 登录密码
}
response = requests.post(url=url, json=data)
code = response.json().get('code')
token = response.headers.get('authorization')
# print(response.json())
# """
# {
# 'code': 0,
# 'message': 'authorization passed.',
# 'data': {
# 'uid': '65dc4187e6e1bf491a4aad1f',
# 'username': 'admin',
# 'role': '超级管理员',
# 'role_type': 1,
# 'token': 'xxxxxxxx'
# }
# }
# """
# --- test 1001 新增用户 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 1001, # 接口号
'username': 'aabbcc', # 登录账户(必须项)
'password': 'aabbcc', # 登录密码(可选项)(默认值:baosteel@2024)
'role_type': 1, # 角色类型(可选项)(1: 超级管理员 2: 普通管理员 3: 普通用户)
'name': 'aabbcc', # 姓名(可选项)
'cid': '112233', # 身份证号(可选项)
'phone': '112233', # 手机号(可选项)
'sex': 0, # 性别(可选项)(0:未设置 1:男 2:女)
'department': 'aabbcc', # 部门(可选项)
'wid': 'aabbcc', # 工号(可选项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 1002 查询用户列表 ---
# url = 'http://58.34.94.177:29101/v6/api'
url = 'http://127.0.0.1:9000/v6/api'
data = {
'code': 1002, # 接口号
'page': 1, # 页码
'size': 3, # 每页条数
'name': 'a', # 模糊姓名(可选项)
'phone': '', # 手机号(可选项)
'role_type': ['2'], # 角色类型(可选项) 1 超级管理员 2 普通管理员 3 普通用户(默认值)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
"""
{
'code': 0,
'data': [
{
'uuid': '65dbeb1c49fbe311a3a01d34',
'name': 'aabbcc',
'cid': '112233',
'phone': '112233',
'sex': 0, # 性别 (0:未设置 1:男 2:女)
'department': 'aabbcc',
'wid': 'aabbcc',
'state': 0, # 禁用状态 (0:激活 1:禁用)
'allow_at': 1708911388 # 注册审批时间时间戳
}
]
}
"""
# --- test 1003 删除指定用户 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 1003, # 接口号
'uuid': '65db84b35e305885648ec062', # 用户id(必须项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 1004 禁用指定用户 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 1004, # 接口号
'uuid': '65decb7744b74ae33732d813', # 用户id(必须项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 1005 启用指定用户 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 1005, # 接口号
'uuid': '65decb7744b74ae33732d813', # 用户id(必须项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 1006 获取指定用户详情 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 1006, # 接口号
'uuid': '65dd775c44b74ae33732d7f7', # 用户id(必须项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 1007 修改指定用户信息 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 1007, # 接口号
'uuid': '65dd775c44b74ae33732d7f7', # 用户id(必须项)
# 'username': 'aabbcc', # 登录账户(必须项)
# 'password': 'aabbcc', # 登录密码(可选项)(默认值:baosteel@2024)
# 'role_type': 3, # 角色类型(可选项)(1: 超级管理员 2: 普通管理员 3: 普通用户)
'name': 'aabbcc', # 姓名(可选项)
# 'cid': '112233', # 身份证号(可选项)
# 'phone': '112233', # 手机号(可选项)
# 'sex': 0, # 性别(可选项)(0:未设置 1:男 2:女)
# 'department': 'aabbcc', # 部门(可选项)
# 'wid': 'aabbcc', # 工号(可选项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 2001 新增车辆 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 2001, # 接口号
'pid': 'AA998877', # 车牌号(必须项)
'type': '112233', # 车型号(可选项)
'host_address': 'xxx.xxx.xxx.xxx', # 工控机地址(可选项)
'rtk_address': 'xxx.xxx.xxx.xxx', # rtk地址(可选项)
'cpe_address': 'xxx.xxx.xxx.xxx', # cpe地址(可选项)
'release_at': '2022-12-12', # 出厂日期(可选项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 2002 查询车辆列表 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 2002, # 接口号
'page': 1, # 页码
'size': 3, # 每页条数
'pid': 'AA', # 模糊查询,车牌号(可选项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
"""
{
'code': 0,
'data': [
{
'uuid': '65dbe96949fbe311a3a01d30',
'pid': 'AA112233',
'type': '112233',
'host_address': 'xxx.xxx.xxx.xxx',
'rtk_address': 'xxx.xxx.xxx.xxx',
'cpe_address': 'xxx.xxx.xxx.xxx',
'release_at': '2022-12-12',
'state': 1, # 当前状态 (1:离线 2:在线空闲 3: 现场驾驶中 4: 远程驾驶中)
'permit_state': 0 # 遥操状态 (0:允许 1:禁用)
}
]
}
"""
# --- test 2003 修改指定车辆信息 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 2003, # 接口号
'uuid': '65dbe96949fbe311a3a01d30', # 车辆id(必须项)
'pid': 'AA112233', # 车牌号(可选项)
'type': '三一/SMHW48', # 车型号(可选项)
'host_address': 'xxx.xxx.xxx.xxx', # 工控机地址(可选项)
'rtk_address': 'xxx.xxx.xxx.xxx', # rtk地址(可选项)
'cpe_address': 'xxx.xxx.xxx.xxx', # cpe地址(可选项)
'release_at': '2022-12-12', # 出厂日期(可选项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 2004 禁止指定车辆远程操作 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 2004, # 接口号
'uuid': '65dbe96949fbe311a3a01d30', # 车辆id(必须项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 2005 允许指定车辆远程操作 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 2005, # 接口号
'uuid': '65dbe96949fbe311a3a01d30', # 车辆id(必须项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 2006 删除指定作业车辆 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 2006, # 接口号
'uuid': '65dd95e244b74ae33732d810', # 车辆id(必须项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 2007 获取指定作业车辆详情 ---
# url = 'http://58.34.94.177:29101/v6/api'
url = 'http://127.0.0.1:9000/v6/api'
data = {
'code': 2007, # 接口号
'uuid': '65de9fa044b74ae33732d811', # 车辆id(必须项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
# --- test 3001 查询驾驶人员操作记录列表 ---
url = 'http://58.34.94.177:29101/v6/api'
data = {
'code': 3001, # 接口号
'page': 1, # 页码
'size': 3, # 每页条数
'pid': 'AA', # 模糊查询,车牌号(可选项)
'driver_name': 'AABBXX', # 模糊查询,驾驶员(可选项)
}
response = requests.post(url=url, json=data, headers={'authorization': token})
print(response.json())
"""
{
'code': 0,
'data': [
{
'uuid': '65dbe96949fbe311a3a01d30',
'pid': 'AA112233',
'start_time_at': 1708917227,
'end_time_at': 1708946027,
'driver_name': '张三',
'cockpit_name': '1号舱'
}
],
'total': 1,
'page': 1,
'size': 3
}
"""
# --- test 3002 下载指定驾驶人员操作日志 ---
url = 'http://58.34.94.177:29101/v6/api'
params = {'code': 3002}
response = requests.get(url=url, params=params, headers={'authorization': token})
print(response.text)
requests.get(url='http://58.34.94.177:29101/v6/api?code=3002').text