getLookupList.py 2.97 KB
# -*- coding: utf-8 -*-

# @Time    : 2021/8/10 17:40
# @Author  : Ljq
# @File    : getLookupList.py
# @Software: PyCharm

"""
进门列表基础数据获取接口
"""

import json,time,random,re
from commons.scripts import dealContentType as dct
from commons.scripts import jsonToUrlcode
from commons.MySession import my

def get_LookupList(host="",providerName="车型"):
    """基础数据获取接口
    :param  providerName:
    :return:
            [{'text': '蔬菜', 'value': '14152'}]
    """
    providerDict = {"车型": "carTypeForJmsfProvider", "货物品类": "categoryProvider", "接车部门": "authDepartmentProvider",
                    "称重类型": "entranceFeeBillTypeProvider", "状态": "entranceFeeBillStateProvider",
                    "交易类型": "tradeTypeProvider"}
    url = host + "/provider/getLookupList.action"
    # print(providerName)
    data = {"provider":providerDict[providerName]}
    headers = dct.urlCode()
    res = my.useHeadersRequests(method="POST", url=url, data=data, headers=headers)
    return res

def get_reach(host="",depId="56"):
    """通过部门编号获取区域"""
    url = host + "/api/jmsf/ajax/district/search.action"
    data = {"depId":depId}
    headers = dct.urlCode()
    res = my.useHeadersRequests(method="POST", url=url, data=data, headers=headers)
    return res

def get_product(host="",productName="蔬菜"):
    """通过部门编号获取区域"""
    url = host + f"/category/search.action?name={productName}"
    data = {"name":productName,"keyword":productName}
    headers = dct.urlCode()
    res = my.useHeadersRequests(method="get", url=url, params=data, headers=headers)
    return res

def get_templateUnit(host="",moduleCode="ZC"):
    """通过部门编号获取区域"""
    print(my.userInfo["data"]["user"]["firmId"])
    marketCode = my.userInfo["data"]["user"]["firmId"]
    url = host + f"/jmsf-web/api/template/getTemplateUnit?marketCode={marketCode}&moduleCode={moduleCode}"
    headers = dct.urlCode()
    res = my.useHeadersRequests(method="get", url=url, headers=headers)
    return res

def get_templateAttr(host="http://test.gateway.diligrp.com:8285",moduleCode="ZC"):
    attr_list = [i["unitName"] for i in get_templateUnit(host=host,moduleCode=moduleCode).json()["data"]]
    return attr_list

def get_config(host="",marketId="9"):
    """通过部门编号获取区域"""
    url = host + "/assets-service/api/config/query"
    data = {"marketId":marketId,"pageNum":100,"pageSize":100}
    headers = dct.jsonCode()
    res = my.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
    return res

# # host="http://test.jmsf.diligrp.com:8385"
# host="http://test.gateway.diligrp.com:8285"
# # print(get_LookupList(host=host,providerName="货物品类").json())
# # print(get_reach(host).json())
# # print(get_category(host=host,productName="蔬菜").json())
# # print(get_templateAttr(host=host))
# print([i["value"] for i in get_config(host=host).json()["rows"] if i["name"]=="DepartmentId"][0])