Commit f9d5f80c by 岳巧源

add push mq

parent fa0c168c
Showing with 48 additions and 5 deletions
...@@ -33,6 +33,7 @@ config_prod = { ...@@ -33,6 +33,7 @@ config_prod = {
} }
} }
def push_mq(message: str, queue_name: str, routing_key: str): def push_mq(message: str, queue_name: str, routing_key: str):
credentials = pika.PlainCredentials(username=username, password=password) credentials = pika.PlainCredentials(username=username, password=password)
conn = pika.BlockingConnection(pika.ConnectionParameters( conn = pika.BlockingConnection(pika.ConnectionParameters(
...@@ -49,7 +50,8 @@ def push_mq(message: str, queue_name: str, routing_key: str): ...@@ -49,7 +50,8 @@ def push_mq(message: str, queue_name: str, routing_key: str):
def post_msg(conf: dict): def post_msg(conf: dict):
db = pymysql.connect(host=conf["mysql"]["host"], port=3306, user=conf["mysql"]["user"], password=conf["mysql"]["password"], database=conf["mysql"]["database"]) db = pymysql.connect(host=conf["mysql"]["host"], port=3306, user=conf["mysql"]["user"],
password=conf["mysql"]["password"], database=conf["mysql"]["database"])
cursor = db.cursor() cursor = db.cursor()
sql = "SELECT spu_id, sku_id FROM lie_shop_push_sku_log WHERE platform = 1 and create_time > 1730368800 and UPDATE_time < 1730851200 and ware_id != '' ORDER BY create_time desc" sql = "SELECT spu_id, sku_id FROM lie_shop_push_sku_log WHERE platform = 1 and create_time > 1730368800 and UPDATE_time < 1730851200 and ware_id != '' ORDER BY create_time desc"
cursor.execute(query=sql) cursor.execute(query=sql)
...@@ -67,6 +69,7 @@ def post_msg(conf: dict): ...@@ -67,6 +69,7 @@ def post_msg(conf: dict):
} }
msg_str = json.dumps(data, ensure_ascii=False) msg_str = json.dumps(data, ensure_ascii=False)
# {"goods_id":1170115972487102103,"spu_id":2170115972437912400,"platform":1,"shop_id":1} # {"goods_id":1170115972487102103,"spu_id":2170115972437912400,"platform":1,"shop_id":1}
...@@ -74,7 +77,8 @@ def post_jd_is_null(conf: dict): ...@@ -74,7 +77,8 @@ def post_jd_is_null(conf: dict):
""" """
将 lie_shop_picture中 pdf 为空的 推送到队列中 将 lie_shop_picture中 pdf 为空的 推送到队列中
""" """
db = pymysql.connect(host=conf["mysql"]["host"], port=3306, user=conf["mysql"]["user"], password=conf["mysql"]["password"], database=conf["mysql"]["database"]) db = pymysql.connect(host=conf["mysql"]["host"], port=3306, user=conf["mysql"]["user"],
password=conf["mysql"]["password"], database=conf["mysql"]["database"])
cursor = db.cursor() cursor = db.cursor()
sql = "select spu_id from lie_shop_picture WHERE jd_pdf = '' and spu_id != 0 ORDER BY create_time desc" sql = "select spu_id from lie_shop_picture WHERE jd_pdf = '' and spu_id != 0 ORDER BY create_time desc"
cursor.execute(query=sql) cursor.execute(query=sql)
...@@ -94,6 +98,46 @@ def post_jd_is_null(conf: dict): ...@@ -94,6 +98,46 @@ def post_jd_is_null(conf: dict):
print("push msg : %s" % msg_str) print("push msg : %s" % msg_str)
if __name__ == '__main__': if __name__ == '__main__':
post_jd_is_null(config_prod) sku_data_1 = {
\ No newline at end of file "goods_id": 1151127267211909500,
"spu_id": 2151042549648798802,
"platform": 1,
"shop_id": 2,
"sku_sn": "1151127267211909500_1",
}
sku_data_2 = {
"goods_id": 1151127267211909500,
"spu_id": 2151042549648798802,
"platform": 1,
"shop_id": 2,
"sku_sn": "1151127267211909500_2",
}
sku_data_3 = {
"goods_id": 1151127267211909500,
"spu_id": 2151042549648798802,
"platform": 1,
"shop_id": 2,
"sku_sn": "1151127267211909500_3",
}
sku_data_4 = {
"goods_id": 1151127267211909500,
"spu_id": 2151042549648798802,
"platform": 1,
"shop_id": 2,
"sku_sn": "1151127267211909500_4",
}
sku_data_5 = {
"goods_id": 1151127267211909500,
"spu_id": 2151042549648798802,
"platform": 1,
"shop_id": 2,
"sku_sn": "1151127267211909500_5",
}
msg_str1 = json.dumps(sku_data_1, ensure_ascii=False)
msg_str2 = json.dumps(sku_data_2, ensure_ascii=False)
msg_str3 = json.dumps(sku_data_3, ensure_ascii=False)
msg_str4 = json.dumps(sku_data_4, ensure_ascii=False)
msg_str5 = json.dumps(sku_data_5, ensure_ascii=False)
push_mq(msg_str1, "liexin_nplm_filter_sku_data", "liexin_nplm_filter_sku_data")
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