From 3ced4879bc60da3317a7d74be761731cf387a5ce Mon Sep 17 00:00:00 2001 From: Ching Date: Wed, 25 Sep 2024 22:15:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E4=BF=AE=E5=A4=8D=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=95=86=E5=93=81=E6=97=B6=E6=9D=A1=E7=A0=81=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=9C=89=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 782f8d1..ad17e05 100644 --- a/app.py +++ b/app.py @@ -121,7 +121,7 @@ def add_product(dict_good, location): if dict_good["gtin"].startswith("0"): data_barcode = { "product_id": int(response_grocy["created_object_id"]), - "barcode": dict_good["gtin"].strip("0"), + "barcode": dict_good["gtin"].lstrip("0"), } grocy.add_generic(EntityType.PRODUCT_BARCODES, data_barcode) @@ -382,13 +382,13 @@ def consume_stream(): logger.info(f"Skip non-numeric barcode: {msg['data']}") continue - _, status_code = handle_add_product(msg['data'], '') + resp, status_code = handle_add_product(msg['data'], '') if status_code == 200: # 消费完成后确认消息 r.xack(STREAM_KEY, CONSUMER_GROUP, msg_id) bark_push('商品添加成功', '条形码 %s' % msg['data']) else: - logger.error(f"Failed to process message: {msg['data']}") + logger.error(f"Failed to process message: {msg['data']} {resp}") bark_push('商品添加失败', '条形码 %s' % msg['data']) except Exception as e: