zcApi.py
10.6 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# -*- coding: utf-8 -*-
# @Time : 2021/7/28 11:14
# @Author : Ljq
# @File : zcApi.py
# @Software: PyCharm
"""
整车进门相关接口
"""
import json,time,random
from commons.scripts import dealContentType as dct
from commons.MySession import my
def get_carType(host="",**kwargs):
"""车型获取"""
url = host + "/jmsf-web/api/jmsf/query/listCarType"
data = {"businessCode":"jmsf"}
headers = dct.jsonCode()
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
return res
def get_listCategoryByCondition(host="",**kwargs):
"""商品获取"""
url = host + "/assets-service/api/cusCategory/getTree"
# marketId = my.userInfo()[]
data = {"marketId":9,"state":1,"keyword":"蔬菜"}
headers = dct.jsonCode()
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
return res
def get_listByExample(host="",**kwargs):
"""获取接车员信息"""
url = host + "/dili-uap/userApi/listByExample.api"
data = {"firmCode":"sy","departmentId":58,"keyword":""}
headers = dct.jsonCode()
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
return res
def get_proveType(host="",**kwargs):
"""查询证明类型"""
url = host + "/jmsf-web/api/jmsf/query/listCodeByPid"
data = {"pid":"prove_type"}
headers = dct.jsonCode()
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="get", url=url, params=json.loads(json.dumps(data)), headers=headers)
return res
def query_transactionType(host="",**kwargs):
"""查交易类型"""
url = host + "/assets-service/api/tradeType/query"
data = {"pageNum":100,"pageSize":100,"marketId":9}
headers = dct.jsonCode()
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
return res
def get_goodsTag(host="",**kwargs):
"""获取货物标签"""
url = host + "/jmsf-web/api/jmsf/query/listCodeByPid"
data = {"pid":"goods_tag"}
headers = dct.jsonCode()
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="get", url=url, params=json.loads(json.dumps(data)), headers=headers)
return res
def get_address(host="",**kwargs):
"""产地获取"""
url = host + "/jmsf-web/api/jmsf/query/address"
data = {"province":"C","city":None,"area":None}
headers = dct.jsonCode()
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
return res
def get_dep(host="",**kwargs):
"""获取部门信息"""
url = host + "/jmsf-web/api/jmsf/query/dep"
data = {"keyword":""}
headers = dct.jsonCode()
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="get", url=url, data=json.dumps(data), headers=headers)
return res
def get_duplicateToken(host=""):
"""进门防重接口"""
url = host + "/jmsf-web/appCommon/duplicateToken.action"
headers = dct.jsonCode()
res = my.useHeadersRequests(method="get", url=url, headers=headers)
return res
def create_wholeCarWeighSave(host="",duplicateToken=None,**kwargs):
"""查询证明类型
:param host:
:param **kwargs:
{
"carTypeCode": "${carTypeCode}",
"carTypeId": ${carTypeId},
"carTypeName": "${carTypeName}",
"carTypeWeight": ${carTypeWeight},
"plate": "${plate}",
"inGreeterId": 0,
"inGreeterName": null,
"productId": ${productId},
"productName": "${productName}",
"proveTypeCode": ${proveTypeCode},
"proveTypeName": "${proveTypeName}",
"weighRemark": "",
"weighmanRecord": {
"grossWeight": ${grossWeight},
"grossWeightDate": "${grossWeightDate}",
"newWeight":${grossWeight},
"tareWeight": ${tareWeight},
"tareWeightDate": null,
"weighImgs": []
},
"productCode": null,
"trailerNumber": "${plate}",
"pathAddress": "A4-BB-6D-0A-F4-13",
"haveTruckWeight": false,
"source": 4,
"entryPlateInputType": 1,
"dep": ${feeDepId},
"depName": "${feeDepName}",
"cateId": ${cateId},
"notice": 0,
"backSkinTwo": -1,
"recordOriginId": 0,
"recordOriginName": null,
"recordProductId": 0,
"recordProductName": null,
"recordWeight": null,
"codeIc": null,
"codeId": 0,
"difference": 0,
"bindRecordSign": 0,
"recordDesc": null,
"hasCodeItems": false,
"customerId": 0,
"customerName": "",
"driverIc": "",
"driverName": "",
"totalPrice": null,
"originId": ${originId},
"origin": "${origin}",
"originCode": "${originCode}",
"tradeType": "${tradeType}",
"tradeTypeName": "${tradeTypeName}",
"weight": ${grossWeight},
"pwd": "",
"type": 1,
"ic": "",
"boothNumber": "210622124244",
"productState": ${productState},
"accountId": 0,
"passCheckId": 0,
"passCheckName": null,
"tradeTypeId": ${tradeTypeId},
"id": 0,
"protocolId": null,
"goodsTagId": ${goodsTagId}
}
:return:"""
url = host + "/jmsf-web/api/entrace/wholeCarWeighSave"
data = {"carTypeCode": "003", "carTypeId": 53, "carTypeName": "板车", "carTypeWeight": 333, "plate": "213123",
"inGreeterId": 223, "inGreeterName": "测试沈阳", "productId": 14152, "productName": "蔬菜", "proveTypeCode": 665,
"proveTypeName": "食品安全", "weighRemark": "备注",
"weighmanRecord": {"grossWeight": 3.0, "grossWeightDate": "2021-07-28 16:28:24", "newWeight": 2.0,
"tareWeight": 1.0, "tareWeightDate": None, "weighImgs": []}, "productCode": None,
"trailerNumber": "", "pathAddress": "A4-BB-6D-0A-F4-13", "haveTruckWeight": False, "source": 4,
"entryPlateInputType": 1, "dep": 58, "depName": "水果部", "cateId": 14152, "notice": 0, "backSkinTwo": -1,
"recordOriginId": 0, "recordOriginName": None, "recordProductId": 0, "recordProductName": None,
"recordWeight": None, "codeIc": None, "codeId": 0, "difference": 0, "bindRecordSign": 0, "recordDesc": None,
"hasCodeItems": False, "customerId": 0, "customerName": "", "driverIc": None, "driverName": None,
"totalPrice": None, "originId": 500101, "origin": "万州区", "originCode": "023", "tradeType": "9001",
"tradeTypeName": "沈阳1号", "weight": 2.0, "pwd": "", "type": 1, "ic": "", "boothNumber": "210728154359",
"productState": 1, "accountId": 0, "passCheckId": 0, "passCheckName": None, "tradeTypeId": 70, "id": 0,
"protocolId": None, "goodsTagId": 663}
headers = dct.jsonCode()
headers["jmsf_duplicate_commit_token"] = duplicateToken
data = dict(data, **kwargs)
res = my.useHeadersRequests(method="POST", url=url, data=json.dumps(data), headers=headers)
return res
def create_jmsf(host=None,keyword="蔬菜",newWeight=99,plate="川A12345"):
"""
"""
# 获取车型
carType = get_carType(host=host)
print(carType.text)
print(carType.json()["data"][0])
carTypeCode = carType.json()["data"][0]["code"]
carTypeId = carType.json()["data"][0]["id"]
carTypeName = carType.json()["data"][0]["carTypeName"]
carTypeWeight = carType.json()["data"][0]["weight"]
# 获取商品
categoryByCondition = get_listCategoryByCondition(host=host,keyword=keyword)
print(categoryByCondition.json())
cateId = categoryByCondition.json()["data"][0]["id"]
productId = categoryByCondition.json()["data"][0]["id"]
productName = categoryByCondition.json()["data"][0]["name"]
productCode = categoryByCondition.json()["data"][0]["keycode"]
# 获取商品
listByExample = get_listByExample(host=host)
print(listByExample.json())
inGreeterId = listByExample.json()["data"][0]["id"]
inGreeterName = listByExample.json()["data"][0]["realName"]
# 获取交易类型
transactionType = query_transactionType(host=host)
print(transactionType.json())
tradeType = transactionType.json()["rows"][0]["code"]
tradeTypeId = transactionType.json()["rows"][0]["id"]
tradeTypeName = transactionType.json()["rows"][0]["name"]
# 获取货物标签
goodsTag = get_goodsTag(host=host)
print(goodsTag.json())
goodsTagId = goodsTag.json()["data"][0]["id"]
# 产地信息获取
address = get_address(host=host)
print(address.json())
originId = address.json()["data"][0]["id"]
origin = address.json()["data"][0]["name"]
originCode = address.json()["data"][0]["cityCode"]
# 查询部门信息
depRes = get_dep(host=host)
print(depRes.json())
feeDepId = depRes.json()["data"][0]["id"]
feeDepName = depRes.json()["data"][0]["name"]
# 获取证明类型
proveType = get_proveType(host=host)
print(proveType.json())
proveTypeCode = proveType.json()["data"][0]["id"]
proveTypeName = proveType.json()["data"][0]["name"]
# 获取防重token
duplicateTokenRes = get_duplicateToken(host=host)
print(duplicateTokenRes.json())
duplicateToken = duplicateTokenRes.json()["data"]
# 创建生成进门单
plate = plate
productState = "1"
trailerNumber = plate
# 重量信息准备
newWeight = newWeight
tareWeight = carTypeWeight
weighmanRecord = {"grossWeight": None, "grossWeightDate": "", "newWeight": None, "tareWeight": None,
"tareWeightDate": None, "weighImgs": []}
weighmanRecord["grossWeight"] = carTypeWeight+newWeight
weighmanRecord["tareWeight"] = carTypeWeight
weighmanRecord["newWeight"] = newWeight
weighmanRecord["grossWeightDate"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
# 创建进门单
cre_res = create_wholeCarWeighSave(host=host, duplicateToken=duplicateToken,
carTypeCode=carTypeCode, carTypeId=carTypeId,
carTypeName=carTypeName, carTypeWeight=carTypeWeight, plate=plate,
productId=productId, productName=productName, proveTypeCode=proveTypeCode,
proveTypeName=proveTypeName, trailerNumber=trailerNumber, depName=feeDepName,
cateId=cateId, originId=originId, origin=origin, originCode=originCode,
tradeType=tradeType, tradeTypeName=tradeTypeName, productState=productState,
tradeTypeId=tradeTypeId, goodsTagId=goodsTagId, inGreeterId=inGreeterId,
inGreeterName=inGreeterName, dep=feeDepId, weighmanRecord=weighmanRecord)
print(cre_res.json())
return cre_res