fix(api): 修复创建商品时条码保存有误的问题
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fe3b5596d3
commit
3ced4879bc
6
app.py
6
app.py
@ -121,7 +121,7 @@ def add_product(dict_good, location):
|
|||||||
if dict_good["gtin"].startswith("0"):
|
if dict_good["gtin"].startswith("0"):
|
||||||
data_barcode = {
|
data_barcode = {
|
||||||
"product_id": int(response_grocy["created_object_id"]),
|
"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)
|
grocy.add_generic(EntityType.PRODUCT_BARCODES, data_barcode)
|
||||||
|
|
||||||
@ -382,13 +382,13 @@ def consume_stream():
|
|||||||
logger.info(f"Skip non-numeric barcode: {msg['data']}")
|
logger.info(f"Skip non-numeric barcode: {msg['data']}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
_, status_code = handle_add_product(msg['data'], '')
|
resp, status_code = handle_add_product(msg['data'], '')
|
||||||
if status_code == 200:
|
if status_code == 200:
|
||||||
# 消费完成后确认消息
|
# 消费完成后确认消息
|
||||||
r.xack(STREAM_KEY, CONSUMER_GROUP, msg_id)
|
r.xack(STREAM_KEY, CONSUMER_GROUP, msg_id)
|
||||||
bark_push('商品添加成功', '条形码 %s' % msg['data'])
|
bark_push('商品添加成功', '条形码 %s' % msg['data'])
|
||||||
else:
|
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'])
|
bark_push('商品添加失败', '条形码 %s' % msg['data'])
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user