diff --git a/xumu.py b/xumu.py index f649142..1c4b58c 100644 --- a/xumu.py +++ b/xumu.py @@ -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是否为0,0 则代表是RFID设备,需要做一个映射 + # 判断t是否为0,0则代表是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()) - r = r.json() - if r["code"] != 200: - return BaseResponse(code=500, msg=r) + if r.status_code == 200: + r = r.json() + if r["code"] != 200: + 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)],