hpApi.py 3.13 KB
# -*- coding: utf-8 -*-

# @Time    : 2021/8/12 17:04
# @Author  : Ljq
# @File    : hpApi.py
# @Software: PyCharm

"""
回皮相关接口
"""

import json,time,random
from commons.scripts import dealContentType as dct
from commons.api.sy import zcApi

host = "http://test.gateway.diligrp.com:8285"

def get_listBackSkinTrucks(session=None,host="",**kwargs):
    """获取接车员信息"""
    url = host + "/jmsf-web/api/jmsf/query/listBackSkinTrucks"
    data = {"plate":"","number":"","customerName":""}
    headers = dct.jsonCode()
    data = dict(data, **kwargs)
    res = session.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
    return res

def backSkinWeighSave(session=None,host="",**kwargs):
    """获取接车员信息"""
    url = host + "/jmsf-web/api/entrace/backSkinWeighSave"
    data = {"hasStoreTruck": 1, "number": "202108120900052", "outGreeterId": 223, "outGreeterName": "测试沈阳",
            "plate": "川B00001", "rail": 1, "tareWeight": 343.0, "tareWeightDate": "2021-08-12 17:18:19",
            "weighImgs": [], "weighId": 0, "remark": "123", "carTypeWeight": 333.0, "trailerNumber": "川B00001",
            "pathAddress": "A4-BB-6D-0A-F4-13", "bskinWithGoods": -1, "ic": "", "customerName": None, "customerId": 0,
            "carTypeCode": "003", "carTypeId": 53, "carTypeName": "板车"}
    headers = dct.jsonCode()
    data = dict(data, **kwargs)
    res = session.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
    return res

def do_backSkinWeighSave(session=None,host="",number=None,userName=None):
    orderInfo = get_listBackSkinTrucks(session=session,host=host,number=number).json()["data"][0]
    print(orderInfo)
    # 参数
    number=number
    plate = orderInfo["plate"]
    carTypeWeight=orderInfo["carTypeWeight"]
    grossWeight=orderInfo["grossWeight"]
    tareWeight=random.randint(carTypeWeight,grossWeight)
    trailerNumber=orderInfo["trailerNumber"]
    carTypeCode=orderInfo["carTypeCode"]
    carTypeId=orderInfo["carTypeId"]
    carTypeName=orderInfo["carTypeName"]
    tareWeightDate=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

    # 获取接车员信息
    listByExample = zcApi.get_listByExample(session=session, host=host)
    print(listByExample.json())
    if userName == None:
        listByExampleIndex = 0
    else:
        listByExampleIndex = listByExample.json()["data"].index(
            [i for i in listByExample.json()["data"] if i["userName"] == userName][0])
    outGreeterId = listByExample.json()["data"][listByExampleIndex]["id"]
    outGreeterName = listByExample.json()["data"][listByExampleIndex]["realName"]

    res_HP = backSkinWeighSave(session=session,host=host,number=number,tareWeight=tareWeight,carTypeWeight=carTypeWeight,
                              plate=plate,trailerNumber=trailerNumber,carTypeCode=carTypeCode,
                              carTypeId=carTypeId,carTypeName=carTypeName,tareWeightDate=tareWeightDate,
                              outGreeterId=outGreeterId,outGreeterName=outGreeterName)
    print(res_HP.json())
    return res_HP,tareWeight



# do_backSkinWeighSave(host=host,number="202108120900062")