Commit a5a9057d by lzzzzl

更新attr_values mongo处理

parent a8f1faf6
......@@ -9,3 +9,6 @@ out
log
gen
/config/db_config.py
# Python files
Test.py
......@@ -205,7 +205,34 @@ class ParamData(object):
(attr_id, value, attr_unit_id, status, remark, add_time, update_time)
DBHandler.insert(class_conn, sql)
"""
读取SKU 数据
"""
@staticmethod
def get_sku_data(idx, sku_conn):
sql = "SELECT old_goods_id,spu_id,goods_id FROM lie_sku_%d WHERE supplier_id = 7" % idx
return DBHandler.read(sku_conn, sql)
\ No newline at end of file
return DBHandler.read(sku_conn, sql)
"""
获取参数名称
"""
@staticmethod
def get_attr_name(attr_id, class_conn):
sql = "SELECT attr_name FROM lie_class_attr WHERE attr_id=%s" % attr_id
return DBHandler.read(class_conn, sql)
"""
获取参数值
"""
@staticmethod
def get_attr_value(attr_value_id, class_conn):
sql = "SELECT value FROM lie_class_attr_value WHERE attr_value_id=%s" % attr_value_id
return DBHandler.read(class_conn, sql)
"""
获取参数单位
"""
@staticmethod
def get_attr_unit(attr_unit_id, class_conn):
sql = "SELECT attr_unit_name FROM lie_class_attr_unit WHERE attr_unit_id=%s" % attr_unit_id
return DBHandler.read(class_conn, sql)
......@@ -6,6 +6,7 @@ from param_task.task import Task
from param_task.value_task_all import ValueTaskAll
from utils.log_handler import LogHandler
import json
import time
class DbAttrValueAll(Task):
......@@ -106,8 +107,8 @@ class DbAttrValueAll(Task):
break
if len(dgk_list) > 0:
self.param_data.update_spu(int(spu_id), json.dumps(dgk_list), spu_db,
self.log2)
time.sleep(0.1)
self.param_data.update_spu(int(spu_id), json.dumps(dgk_list), spu_db, self.log2)
if count % 3000 == 0:
self.log1.info("INDEX: {INDEX}, COUNT: {COUNT}".format(INDEX=param_index, COUNT=count))
except:
......
......@@ -3,8 +3,8 @@ import json
import traceback
import pymongo
from urllib import parse
from utils.mysql_handler import MysqlHandler
from fun.param_thread import ParamThread
from fun.param_data import ParamData
# 转义用户名和密码
......@@ -21,7 +21,7 @@ mycol = mydb["spu_attrs"]
class ParamMongo(object):
def __init__(self):
self.mysql_handler = MysqlHandler('liexin_spu')
self.param_data = ParamData
self.data_dict = {0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: []}
"""
......@@ -51,9 +51,9 @@ class ParamMongo(object):
new_av_list = list()
for vals in attr_values:
val = str(vals).split(",")
attr_name = self.mysql_handler.get_attr_name(val[0])
attr_value = self.mysql_handler.get_attr_value(val[1])
attr_unit = self.mysql_handler.get_attr_unit(val[2])
attr_name = self.param_data.get_attr_name(val[0])
attr_value = self.param_data.get_attr_value(val[1])
attr_unit = self.param_data.get_attr_unit(val[2])
if attr_name and attr_value and attr_unit:
new_av_list.append({'attr_name': attr_name, 'attr_value': attr_value, 'attr_unit': attr_unit})
self.search_mongo(spu_id, new_av_list)
......
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