Commit 325a8d95 by 岳巧源

add sku_file_id

parent c301d52c
Showing with 7 additions and 5 deletions
...@@ -70,7 +70,7 @@ def is_number(s: str): ...@@ -70,7 +70,7 @@ def is_number(s: str):
pass pass
return False return False
def resolve(file_name: str, supplier_id: int): def resolve(file_name: str, supplier_id: int, sku_file_id: int):
producer = Producer() producer = Producer()
df = pd.read_excel(file_name, sheet_name=0) df = pd.read_excel(file_name, sheet_name=0)
for i in range(len(df.index.values)): for i in range(len(df.index.values)):
...@@ -124,7 +124,8 @@ def resolve(file_name: str, supplier_id: int): ...@@ -124,7 +124,8 @@ def resolve(file_name: str, supplier_id: int):
"batch_sn": batch_sn, "batch_sn": batch_sn,
"ladder_price": [], "ladder_price": [],
"goods_sn": "", "goods_sn": "",
"mpq": mpq "mpq": mpq,
"sku_file_id": int(sku_file_id),
} }
normal_text = (goods_name + brand_name + str(supplier_id) + str(df.loc[i, "封装"]) + str(df.loc[i, "批次"])).lower() normal_text = (goods_name + brand_name + str(supplier_id) + str(df.loc[i, "封装"]) + str(df.loc[i, "批次"])).lower()
md = hashlib.md5(normal_text.encode()) md = hashlib.md5(normal_text.encode())
...@@ -152,7 +153,7 @@ def resolve(file_name: str, supplier_id: int): ...@@ -152,7 +153,7 @@ def resolve(file_name: str, supplier_id: int):
producer.close() producer.close()
def process(url: str, supplier_id: int): def process(url: str, supplier_id: int, sku_file_id: int):
# http://erp.liexindev.net/sku/20240823/p6jMKaPtjMpNnZMK5vEX3KEQf7Gdvgvw3TCA7d6b.xls # http://erp.liexindev.net/sku/20240823/p6jMKaPtjMpNnZMK5vEX3KEQf7Gdvgvw3TCA7d6b.xls
abs_path = "" abs_path = ""
try: try:
...@@ -163,7 +164,7 @@ def process(url: str, supplier_id: int): ...@@ -163,7 +164,7 @@ def process(url: str, supplier_id: int):
abs_path = absolute_path abs_path = absolute_path
with open(absolute_path, "wb") as f: with open(absolute_path, "wb") as f:
f.write(response.content) f.write(response.content)
resolve(absolute_path, supplier_id) resolve(absolute_path, supplier_id, sku_file_id)
except Exception as e: except Exception as e:
logging.error(e) logging.error(e)
finally: finally:
......
...@@ -10,7 +10,8 @@ def callback(ch, method, properties, body): ...@@ -10,7 +10,8 @@ def callback(ch, method, properties, body):
url = str(data["file_address"]) url = str(data["file_address"])
url = url.replace("\\", "") url = url.replace("\\", "")
supplier_id = data["supplier_id"] supplier_id = data["supplier_id"]
handle.process(url, supplier_id) sku_file_id = data["sku_file_id"]
handle.process(url, supplier_id, sku_file_id)
except Exception as e: except Exception as e:
print(e) print(e)
ch.basic_ack(delivery_tag=method.delivery_tag) ch.basic_ack(delivery_tag=method.delivery_tag)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment