cardStorageIn.py
3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#coding=utf-8
# @Time : 2021/7/16 14:09
# @Author : Ljq
# @File : cardStorageIn.py
# @Software: PyCharm
"""
入库列表相关接口
"""
import requests
import json
from commons.readConf import readConfig
print("cSI")
# rC = readConfig()
# cardHost = rC.returnOptionsItems("host","cardHost")
def getCardType(cardHost,webHeaders):
"""
获取卡片类型列表
:param cardHost:
:param webHeaders:
:return:
"""
url = cardHost+"/provider/getLookupList.action"
webHeaders["Content-Type"] = "application/x-www-form-urlencoded"
data={"provider":"cardTypeProvider","queryParams":'{"emptyText":"-- 全部 --"}'}
res = requests.post(url=url,headers=webHeaders,data=data)
return res
def getCardFace(cardHost,webHeaders):
"""
获取卡面信息列表
:param cardHost:
:param webHeaders:
:return:
"""
url = cardHost+"/provider/getLookupList.action"
webHeaders["Content-Type"] = "application/x-www-form-urlencoded"
data={"provider":"cardFaceProvider","queryParams":'{emptyText:"-- 请选择 --"}'}
res = requests.post(url=url,headers=webHeaders,data=data)
return res
def returnFaceValue(resCardFace,faceNum):
"""
根据faceNum获取对应卡面的value,目前卡面faceNum值为1-4
:param resCardFace:
:param faceNum:
:return:
"""
# print("resCardFace",type(resCardFace))
if resCardFace.json()[0]["text"] == "-- 无--":
# 业务需求当存在 卡面 “--无--” 时,入库不需要传递cardFace
cardFace = None
else:
cardFace = resCardFace.json()[faceNum]["value"]
return cardFace
def savaCard(cardHost,webHeaders,startCardNo,endCardNo,cardType=10,cardFace=None):
"""
卡片入库接口
:param cardHost:
:param webHeaders:
:param startCardNo:
:param endCardNo:
:param cardType:
:param cardFace:
:return:
"""
amount = int(endCardNo)-int(startCardNo)+1
url = cardHost + "/cardStorageIn/save.action"
if cardFace == None:
# 当卡面类型为无时,创建入库时,不能传faceNum
data = {"cardType": str(cardType), "startCardNo": str(startCardNo), "endCardNo": str(endCardNo), "amount": amount}
else:
data = {"cardType": str(cardType), "cardFace": cardFace, "startCardNo": str(startCardNo), "endCardNo": str(endCardNo), "amount": amount}
webHeaders["Content-Type"] = "application/json; charset=UTF-8"
print("savaCard data ----> ",data)
res = requests.post(url=url, headers=webHeaders, data=json.dumps(data))
return res
def queryList(cardHost=None,webHeaders=None,**searshData):
"""
入库列表查询
:param cardHost:
:param webHeaders:
:param searshData:
:return:
"""
storageInListUrl = cardHost + "/cardStorageIn/queryList.action"
webHeaders["Content-Type"] = "application/x-www-form-urlencoded"
storageInSearshData = {"rows": "10", "page": "1", "sort": "create_time", "order": "desc", "startDate": None,
"endDate": None}
storageInSearshData = dict(storageInSearshData,**searshData)
# print("storageInSearshData[i]---->",storageInSearshData)
res = requests.post(url=storageInListUrl, headers=webHeaders, data=storageInSearshData)
return res
def delCard(cardHost=None,webHeaders=None,ids=None):
"""
删除入库记录
:param cardHost:
:param webHeaders:
:param ids:
:return:
"""
storageInListUrl = cardHost + "/cardStorageIn/del.action"
webHeaders["Content-Type"] = "application/x-www-form-urlencoded"
delCardData = {"ids":ids}
res = requests.post(url=storageInListUrl, headers=webHeaders, data=delCardData)
return res