cardStorageOut.py 3.71 KB
#coding=utf-8

# @Time    : 2021/5/20 17:41
# @Author  : Ljq
# @File    : cardStorageOut.py
# @Software: PyCharm


"""
    卡片出库接口
"""

import requests
import json
import re
import time
from commons.scripts import dealContentType as dCT

def cardAddOut(cardHost=None,webHeaders=None,**kwargs):
    """
    卡片出库接口
    :param cardHost:
    :param webHeaders:
    :param kwargs:
    :return:
    """
    url = cardHost+"/cardStorage/addOut.action"
    webHeaders["Content-Type"] = "application/json; charset=UTF-8"
    data={"applyUserName":"沈阳长歌","applyUserId":"230","applyUserCode":"scgy","amount":"1","cardNos":"210520174412"}
    data = dict(data,**kwargs)
    # print("data---->",data)
    res = requests.post(url=url,headers=webHeaders,data=json.dumps(data))
    return res

def getOutPage(cardHost=None,webHeaders=None,**kwargs):
    """
    出库列表查询
    :param cardHost:
    :param webHeaders:
    :param kwargs:{"rows":"10","page":"1","sort":"apply_time","order":"desc","cardNo":"210524144001","applyUserName":"长歌","applyUserId":"93","startDate":"2021-05-24 00:00:00","endDate":"2021-05-24 23:59:59"}
    :return:
    """
    url = cardHost+"/cardStorage/outPage.action"
    webHeaders["Content-Type"] = "application/x-www-form-urlencoded"
    data = {"rows": "10", "page": "1", "sort": "apply_time", "order": "desc"}
    data = dict(data,**kwargs)
    # print("data---->",data)
    res = requests.post(url=url, headers=webHeaders, data=data)
    return res

def getCardType(cardHost=None,webHeaders=None,**kwargs):
    """
    获取卡片类别
    :param cardHost:
    :param webHeaders:
    :param kwargs:
    :return:
    """
    url = cardHost+"/provider/getLookupList.action"
    webHeaders = dCT.urlCode(webHeaders)
    data = {'provider':'cardTypeProvider','queryParams':'{"emptyText":"-- 请选择 --"}'}
    res = requests.post(url=url,headers=webHeaders,data=data)
    return res

def getCardFace(cardHost=None,webHeaders=None,**kwargs):
    """
    获取卡面信息
    :param cardHost:
    :param webHeaders:
    :param kwargs:
    :return:
    """
    url = cardHost + "/provider/getLookupList.action"
    webHeaders = dCT.urlCode(webHeaders)
    data = {'provider':'cardFaceProvider','queryParams':'{emptyText:"-- 请选择 --"}'}
    res = requests.post(url=url, headers=webHeaders, data=data)
    return res

def checkCardForOut(cardHost=None,webHeaders=None,**kwargs):
    """
    检验当前卡片选择的卡面是否正确
    :param cardHost:
    :param webHeaders:
    :param kwargs:
    :return:
    """
    url = cardHost+"/cardStorage/checkCardForOut.action"
    webHeaders= dCT.urlCode(webHeaders)
    data = {"cardNo":"","cardType":"10","cardFace":""}
    data=dict(data,**kwargs)
    res = requests.get(url=url,headers=webHeaders,params=data)
    return res

def getUserInfo(cardHost=None,webHeaders=None,**kwargs):
    url = cardHost+"/user/listByKeyword.action"
    webHeaders=dCT.urlCode(webHeaders)
    data={"name":"scgy","keyword":"scgy"}
    data=dict(data,**kwargs)
    res = requests.post(url=url,headers=webHeaders,data=data)
    return res

def getOutListDetail(cardHost=None,webHeaders=None,id=None):
    url = cardHost+"/cardStorage/outDetail.html"
    webHeaders = dCT.urlCode(webHeaders)
    data = {"id":str(id)}
    res = requests.get(url=url,headers=webHeaders,params=data)
    return res

def getOutCardDetail(cardHost=None,webHeaders=None,**kwargs):
    listRes = getOutPage(cardHost=cardHost, webHeaders=webHeaders,**kwargs)
    firstId = listRes.json()["rows"][0]["id"]
    # 查询出库详情
    resDetail = getOutListDetail(cardHost=cardHost, webHeaders=webHeaders, id=firstId)
    outCardDetail = re.findall("<ul><li>(.*?)</li></ul>", resDetail.text)
    return sorted(outCardDetail)