This commit is contained in:
xyj 2024-01-25 14:16:47 +08:00
parent 6ae16e0e66
commit d6b91ef776
1 changed files with 9 additions and 11 deletions

14
xumu.py
View File

@ -168,30 +168,28 @@ async def process_data(request: Request):
send_len = payload["l"]
if receive_len != send_len:
print("校验错误,收到的消息长度:", receive_len)
return BaseResponse(code=301, msg="data valid error")
return BaseResponse(code=301, msg=f"data valid error,receive_len:{receive_len}")
m = payload["m"]
v = payload["v"]
t = payload["t"]
deviceId = v[0]
m.append("t")
v.append(t)
res = []
# 判断t是否为00则代表是RFID设备需要做一个映射
if t == 0:
rfid = v[1]
deviceId = v[0]
sql_list = rfid_deviceId(rfid, deviceId)
sql = sql_list[0]
send_json = {
"sql": sql
}
r = requests.post(baseHost + nonQueryUri, headers=headers, json=send_json)
if r.status_code != 200:
return BaseResponse(code=r.status_code, msg=r.json())
if r.status_code == 200:
r = r.json()
if r["code"] != 200:
return BaseResponse(code=500, msg=r)
return BaseResponse(code=500, msg="RFID创建映射失败", data=r)
res.append(r)
deviceId = v[0]
m.append("t")
v.append(t)
send_json = {
"devices": ["root.farm." + deviceId],
"timestamps": [int(time.time() * 1000)],