调接口新增车辆
Posted yanpan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了调接口新增车辆相关的知识,希望对你有一定的参考价值。
# coding = utf-8
import json
import os
import time
import requests
from getExcelData import get_excel_data, root_dir
def login(host, account, password):
headers = {"Content-Type": "application/json;charset=UTF-8"}
url = host + "/travel/admin/authenticate/login"
data = {"account": account, "userPwd": password}
response = requests.post(url=url, headers=headers, data=json.dumps(data))
cookie = response.headers[‘Set-Cookie‘].split(";")[0]
return cookie
def addCar(host, cookie, carModelId, carNo, carVin, colorId, seatsNumber, fileNumber, engineNumber):
url = host + "/travel/admin/car/add"
headers = {"Cookie": cookie, "Content-Type": "application/json;charset=UTF-8"}
data = {
"basic": {
"brandId": "26",
"carModelId": carModelId,
"carNo": carNo,
"companyId": 1,
"useNature": 1,
"carVin": carVin,
"ownerName": "张三",
"ownerAddress": "中盛大厦",
"registrationDate": "2019-02-10",
"certificateDate": "2019-02-01",
"annualInspection": "1",
"annualInspectionDueDate": "2021-02-18",
"carStatus": 10,
"colorId": colorId,
"namePlateTime": "",
"seatsNumber": seatsNumber,
"fileNumber": fileNumber,
"engineNumber": engineNumber,
"certificateNumber": "",
"operationCompanyId": 1,
"carHardware": 1,
"carPurchase": 0,
"drivingLicense": [],
"drivingLicenseUrl": ""
},
"hardwares": [{
"supplier": "全球鹰",
"terminalNumber": engineNumber,
"installationPosition": "11",
# "bluetoothNumber": engineNumber,
"simNumber": str(time.time()).split(".")[1],
"simSupplier": 1,
"simOpenDate": "2020-02-01",
"simExpireDate": "2022-02-28",
"simSetmealStandard": "111",
"paymentCycle": 6
}],
"purchase": None
}
if carModelId == 99:
data["basic"]["carSource"] = 2
else:
data["basic"]["carSource"] = 1
response = requests.post(url=url, headers=headers, data=json.dumps(data))
print(response.text)
if __name__ == "__main__":
account = "13649550277"
password = "admin123!@#$"
cookie = login(account, password)
carModelIdDict = {"EX3": 99, "K17A": 100, "K17AS": 101}
colourDict = {"白色": 128, "红色": 129, "金色":