Commit a70c40f8 by 岳巧源

modify script

parent 38009ae5
Showing with 13 additions and 6 deletions
import hashlib
import json
import os
import logging
import pandas as pd
import pika
import requests
import config
log_path = "/data/golang/src/europa-erp-go/scripts/data_server/py_mq.log"
title_arr = [
"原厂型号",
"品牌",
......@@ -23,6 +23,11 @@ title_arr = [
"封装"
]
logging.basicConfig(level=logging.INFO,
filename=log_path,
format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s'
)
class Producer:
def __init__(self):
credentials = pika.PlainCredentials(username=config.rabbit_mq_user, password=config.rabbit_mq_password)
......@@ -57,12 +62,13 @@ def resolve(file_name: str, supplier_id: int):
brand_name = str(df.loc[i, "品牌"])
if goods_name.strip() == "" or brand_name.strip() == "" or goods_name.strip() == "nan" or brand_name.strip() == "nan":
continue
stock = str(df.loc[i, "库存"])
moq = str(df.loc[i, "起订量"])
stock = str(int(str(df.loc[i, "库存"])))
moq = str(int(str(df.loc[i, "起订量"])))
mpq = str(int(str(df.loc[i, "MPQ(最小包装数量)"])))
price_is_us = False
supp_id = int(supplier_id)
supplier_name = ""
multiple = str(df.loc[i, "增量"])
multiple = str(int(str(df.loc[i, "增量"])))
batch_sn = {
str(df.loc[i, "批次"]): int(df.loc[i, "库存"]),
}
......@@ -82,6 +88,7 @@ def resolve(file_name: str, supplier_id: int):
"batch_sn": batch_sn,
"ladder_price": [],
"goods_sn": "",
"mpq": mpq
}
normal_text = (goods_name + brand_name + str(supplier_id) + str(df.loc[i, "封装"]) + str(df.loc[i, "批次"])).lower()
md = hashlib.md5(normal_text.encode())
......@@ -98,7 +105,7 @@ def resolve(file_name: str, supplier_id: int):
item_map["price_cn"] = float(price_data)
table["ladder_price"].append(item_map)
ans = json.dumps(table, ensure_ascii=False)
print(ans)
logging.info(ans)
producer.push(ans)
producer.close()
......
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