Commit 712e7c3c authored by rico.liu's avatar rico.liu

init

parents
Pipeline #183 canceled with stages
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 23 23:36:40 2021
@author: rico
"""
import requests
def zgc_api(func,data):
headers = {
'Connection': 'Keep-Alive'
}
key = 'eRo1#ZFHY5N&GEzV'
api = f"http://59.110.219.171:8000/{func}/"
print(api)
data.update({'key':key})
session = requests.session()
result = session.post(api,json=data,headers=headers,timeout=6000).json()
return result
#进度条
class Index(object):
def __init__(self, number=50, decimal=2):
"""
:param decimal: 你保留的保留小数位
:param number: # 号的 个数
"""
self.decimal = decimal
self.number = number
self.a = 100/number # 在百分比 为几时增加一个 # 号
def __call__(self, now, total):
# 1. 获取当前的百分比数
percentage = self.percentage_number(now, total)
# 2. 根据 现在百分比计算
well_num = int(percentage / self.a)
# print("well_num: ", well_num, percentage)
# 3. 打印字符进度条
progress_bar_num = self.progress_bar(well_num)
# 4. 完成的进度条
result = "\r%s %s" % (progress_bar_num, percentage)
return result
def percentage_number(self, now, total):
"""
计算百分比
:param now: 现在的数
:param total: 总数
:return: 百分
"""
return round(now / total * 100, self.decimal)
def progress_bar(self, num):
"""
显示进度条位置
:param num: 拼接的 “#” 号的
:return: 返回的结果当前的进度条
"""
# 1. "#" 号个数
well_num = "#" * num
# 2. 空格的个数
space_num = " " * (self.number - num)
return '[%s%s]' % (well_num, space_num)
scp $1 uploadfile@59.110.219.171:/home/zgcAPI/PointCategoryDealFile/
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 24 17:21:29 2021
@author: rico
"""
import pandas as pd
import pymssql
from public import Index
#上传数据字典补充数据
def ComplicatedDataDict(path):
#创建新产品库链接
conn_zi_new = pymssql.connect(host='123.56.115.207', user='zgcprice3311',password='zgcprice20200628',database= 'ZI_NEW',autocommit=True)
cursor_zi_new = conn_zi_new.cursor()
df = pd.read_excel(path)
process_index = 0
index = Index()
for index,row in df.iterrows():
try:
print(index(process_index,len(df)-1), end='%')
except:
print(index(process_index,1), end='%')
process_index+=1
cursor_zi_new.execute(f"update ShuJuZiDian_Cfg set stdvalue = '{row['stdvalue']}',simplevalue = '{row['simplevalue']}' where id = {row['id']}")
conn_zi_new.close()
path = ''
ComplicatedDataDict(path)
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 23 00:36:24 2021
@author: rico
"""
import pandas as pd
import pymssql
from public import Index
def get_point_category_params_data(category):
category_sheet_name = category.replace("/","_")
#创建产品库链接
conn_zi_new = pymssql.connect(host='123.56.115.207', user='zgcprice3311',password='zgcprice20200628',database= 'ZI_NEW',autocommit=True)
cursor = conn_zi_new.cursor()
conn_zdindex = pymssql.connect(host='123.56.115.207', user='zgcprice3311',password='zgcprice20200628',database= 'zdindex',autocommit=True)
cursor_zdindex = conn_zdindex.cursor()
cursor.execute(f"select id,name from p_category where id not in (select distinct pid from p_category) and name in ('{category}')")
data = (cursor.fetchall())
export_category = pd.DataFrame(data,columns=[tuple[0] for tuple in cursor.description])
writer = pd.ExcelWriter(f"{category_sheet_name}参数确认.xlsx")
for category_code,category_name in zip(export_category['id'].tolist(),export_category['name'].tolist()):
print(f"开始提取{category_name}参数数据")
#获取产品信息
cursor.execute(f"select a.*,h.name as father_brand_name,d.name as brand_name,g.name as attr_name,f.value from p_sku a \
left join p_spu b \
on a.spuid = b.id \
left join p_category c \
on b.categoryid = c.id \
left join p_brand d \
on b.brandid = d.id \
left join p_skuvaluemap e \
on a.id = e.skuid \
left join p_skuvalue f \
on e.valueid = f.id \
left join p_skusubtitle g \
on f.subtitleid = g.id \
left join p_brand h \
on d.pid = h.id \
where b.categoryid = {category_code} and a.state in (1,2,4)")
data = (cursor.fetchall())
df_sku = pd.DataFrame(data,columns=[tuple[0] for tuple in cursor.description])
cursor.execute(f"select a.*,d.name as brand_name,g.name as attr_name,f.value from p_sku a \
left join p_spu b \
on a.spuid = b.id \
left join p_category c \
on b.categoryid = c.id \
left join p_brand d \
on b.brandid = d.id \
left join p_valuemap e \
on b.id = e.spuid \
left join p_value f \
on e.valueid = f.id \
left join p_subtitle g \
on f.subtitleid = g.id \
where b.categoryid = {category_code} and a.state in (1,2,4)")
data = (cursor.fetchall())
df_spu = pd.DataFrame(data,columns=[tuple[0] for tuple in cursor.description])
res = pd.DataFrame()
id_list = []
state_list = []
product_name_list = []
father_brand_list = []
brand_list = []
category_list = []
#param_list
cursor.execute(f"select * from vw_property where categoryid = {category_code}")
data = cursor.fetchall()
params_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor.description])
params_df['needed_param'] = params_df['identy'].apply(lambda x: x[0])
params_df['standard_param'] = params_df['identy'].apply(lambda x: x[2])
params_df = params_df[params_df['needed_param'] != '0']
params_df['subtitle'] = params_df['subtitle'].apply(lambda x: x.strip())
param_list = params_df['subtitle'].tolist()
for param in param_list:
param_var = '_' + ''.join(param.split()).replace('(','').replace(')','').replace('/','').replace('(','').replace(')','').replace('+','').replace('-','').replace('*','').replace('.','')
exec('%s_list=[]'%param_var)
process_index = 0
index = Index()
for prodcut_id in list(df_sku['sku'].unique()):
try:
print(index(process_index,len(list(df_sku['sku'].unique()))-1), end='%')
except:
print(index(process_index,1), end='%')
process_index+=1
id_list.append(prodcut_id)
state_list.append(df_sku[df_sku['sku'] == prodcut_id]['state'].tolist()[0])
product_name_list.append(df_sku[df_sku['sku'] == prodcut_id]['skuname'].tolist()[0])
father_brand_list.append(df_sku[df_sku['sku'] == prodcut_id]['father_brand_name'].tolist()[0])
brand_list.append(df_sku[df_sku['sku'] == prodcut_id]['brand_name'].tolist()[0])
category_list.append(category_name)
for param in param_list:
param_var = '_' + ''.join(param.split()).replace('(','').replace(')','').replace('/','').replace('(','').replace(')','').replace('+','').replace('-','').replace('*','').replace('.','')
try:
exec("%s_list.append(df_sku[(df_sku['sku'] == prodcut_id) & (df_sku['attr_name'] == '%s')]['value'].tolist()[0])"%(param_var,param))
except:
try:
exec("%s_list.append(df_spu[(df_spu['sku'] == prodcut_id) & (df_spu['attr_name'] == '%s')]['value'].tolist()[0])"%(param_var,param))
except:
exec("%s_list.append('无参数,需补充')"%param_var)
res['产品编码'] = id_list
res['产品状态'] = state_list
res['产品名称'] = product_name_list
res['产品父品牌'] = father_brand_list
res['产品品牌'] = brand_list
res['产品类别'] = category_list
for index,row in params_df.iterrows():
param = row['subtitle']
needed_flag = row['needed_param']
standard_flag = row['standard_param']
if param == '产品名称':
continue
param_var = '_' + ''.join(param.split()).replace('(','').replace(')','').replace('/','').replace('(','').replace(')','').replace('+','').replace('-','').replace('*','').replace('.','')
#标记标准项
if needed_flag == '1' and standard_flag == '1':
param = '*' + param
exec("res['%s']=%s_list"%(param,param_var))
res.to_excel(writer,f"{category_sheet_name}参数数据")
cursor_zdindex.execute(f"select goods_id,goods_name,platform_id,goods_url,index_price_wave from zd_week_price where periods in (select top 1 max(periods) from zd_entry_goods_price) and sub_category_code = {category_code} ")
data = (cursor_zdindex.fetchall())
price_df = pd.DataFrame(data,columns=[tuple[0] for tuple in cursor_zdindex.description])
price_df.to_excel(writer,f"{category_sheet_name}价格链接数据")
print(f"{category_name}数据导出完毕!")
writer.save()
conn_zi_new.close()
category = '复印纸'
get_point_category_params_data(category)
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 25 10:53:59 2021
@author: rico
"""
import pymssql
import pandas as pd
from public import Index
def transform_simplevalue(cursor_zi_new,shujuzidiandf,categoryname,subtitle,stdvalue):
stdvalue = stdvalue.strip()
simple_subtitle_list = ['CPU型号','显存容量','操作系统','双面器','双面输稿器','网络打印','标配外服务及配件','标配外耗材','镜头描述','碎纸效果']
if subtitle not in simple_subtitle_list:
return stdvalue
simplevalue_list = list(set(shujuzidiandf[(shujuzidiandf['categoryname'] == categoryname) & (shujuzidiandf['subtitle'] == subtitle) & (shujuzidiandf['stdvalue'] == stdvalue)]['simplevalue'].tolist()))
if len(simplevalue_list) == 0:
print(f"非法值,不存在数据字典中。{subtitle},{stdvalue}")
#add_shujuzidian(cursor_zi_new,categoryname,subtitle,stdvalue)
return False
elif len(simplevalue_list) == 1:
if simplevalue_list[0] == '无简称':
#add_shujuzidian(categoryname,subtitle,stdvalue)
return " "
else:
return simplevalue_list[0]
else:
print(f"异常数据,具有多个简称。{subtitle},{stdvalue}")
return False
def dael_name_content(skuname,brand):
#处理产品名称中 括号里的内容
skuname = skuname.replace(brand,'')
name_head = skuname.split('(')[0]
name_tail = skuname.split('(')[1].split(')')[1]
name_content = skuname.split('(')[1].split(')')[0].split('/')
if (len(list(set(name_content))) == 1 and name_content[0] == ' ') or (len(list(set(name_content))) == 2 and ' ' in name_content and '/' in name_content):
if name_tail == '':
res = brand + name_head
else:
res = brand + name_head + " " + name_tail
else:
temp_content = ''
for element in name_content:
if element == ' ':
continue
else:
temp_content += element + '/'
temp_content = "(" + temp_content.strip('/') + ")"
if name_tail == '':
res = brand + name_head + temp_content
else:
if temp_content == '':
res = brand + name_head + " " + name_tail
else:
res = brand + name_head + temp_content + name_tail
return res.strip()
def upload_params_data(category,path):
df = pd.read_excel(path,converters = {'产品编码':str})
#创建新产品库链接
conn_zi_new = pymssql.connect(host='123.56.115.207', user='zgcprice3311',password='zgcprice20200628',database= 'ZI_NEW',autocommit=True)
cursor_zi_new = conn_zi_new.cursor()
##加载库中参数项数据(参数id,参数从属)
cursor_zi_new.execute(f"select * from vw_property where name = '{category}' and identy != '0000'")
db_params = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])
db_params['subtitle'] = db_params['subtitle'].apply(lambda x: x.strip())
subtitle_list = db_params['subtitle'].tolist()
subtitle_id_dict = dict(zip(db_params['subtitle'].tolist(),db_params['subtitleid'].tolist()))
subtitle_type_dict = dict(zip(db_params['subtitle'].tolist(),db_params['skuorspu'].tolist()))
#获取命名规则
cursor_zi_new.execute(f"select * from skuname_named_rule where categoryname = '{category}'")
named_rules_df = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])
if named_rules_df.empty:
print(f"{category}类别无SKU命名规则,无法处理")
return False
named_rule = named_rules_df['rule'].str.cat()
#获取数据字典
cursor_zi_new.execute(f"select * from ShuJuZiDian_Cfg where categoryname = '{category}'")
data_dict = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])
data_dict['stdvalue'] = data_dict['stdvalue'].apply(lambda x : x.upper())
single_data_dict = data_dict
process_index = 0
index_ = Index()
#暂不支持复印纸命名
for index,row in df.iterrows():
try:
print(index_(process_index,len(df)-1), end='%')
except:
print(index_(process_index,1), end='%')
process_index+=1
sku = row['产品编码']
brandname = row['产品品牌']
params = dict(zip(subtitle_list,[row[subtitle] for subtitle in subtitle_list]))
cursor_zi_new.execute(f"select id,spuid from p_sku where sku = '{sku}'")
skuid,spuid = cursor_zi_new.fetchone()
skuname = ''
for element in named_rule.split(" "):
if element == '品牌名称':
value = brandname
elif element == '类别名称':
value = category
elif element[0] == "(" and "/" in element:
element = element.replace("(","").replace(")","")
detail_element_list = element.split("/")
for i in range(len(detail_element_list)):
#value = cat_sku_df[(cat_sku_df['sku'] == sku) & (cat_sku_df['name'] == detail_element_list[i])]['value'].tolist()[0]
value = str(params[detail_element_list[i]])
value = transform_simplevalue(cursor_zi_new,single_data_dict,category,detail_element_list[i],value.upper())
if i == 0:
skuname += "(" + value + "/"
elif i == len(detail_element_list)-1:
skuname += value + ") "
else:
skuname += value + "/"
continue
elif element[0] == "(" and "/" not in element:
element = element.replace("(","").replace(")","")
value = str(params[element])
value = transform_simplevalue(cursor_zi_new,single_data_dict,category,element,value.upper())
skuname += "(" + value + ") "
continue
else:
value = str(params[element])
value = transform_simplevalue(cursor_zi_new,single_data_dict,category,element,value.upper())
skuname += value + " "
skuname = skuname.strip()
#处理名称中的空格
if category in ['复印纸','扫描仪']:
skuname = skuname
elif category in ['笔记本','台式机','一体电脑','碎纸机']:
skuname = dael_name_content(skuname,brandname)
elif category in ['复印机','多功能一体机','单反相机']:
skuname_part1 = skuname.split(category)[0]
skuname_part2 = skuname.split(category)[1]
skuname_1 = dael_name_content(skuname_part1,brandname)
skuname_2 = dael_name_content(skuname_part2,brandname).replace(brandname,"")
skuname = skuname_1 + " " + category + skuname_2
elif category in ['投影机','激光打印机','空调']:
if category == '空调':
skuname_part1 = skuname.split("空调 (")[0].strip()
else:
skuname_part1 = skuname.split(category)[0].strip()
skuname_part2 = skuname.replace("中央空调","").replace("空调扇","").split(category)[1]
skuname_2 = dael_name_content(skuname_part2,brandname).replace(brandname,"")
skuname = skuname_part1 + " " + category + skuname_2
elif category in ['单电/微单相机']:
skuname_part1 = skuname.split(category)[0]
skuname_part2 = skuname.split(category)[1]
skuname_1 = dael_name_content(skuname_part1,brandname)
skuname_2 = dael_name_content(skuname_part2,brandname).replace(brandname,"")
skuname = skuname_1 + " " + category + skuname_2
else:
skuname_part1 = skuname.split(category)[0].strip()
skuname_part2 = skuname.split(category)[1]
skuname_2 = dael_name_content(skuname_part2,brandname).replace(brandname,"")
skuname = skuname_part1 + " " +category + skuname_2
cursor_zi_new.execute(f"update p_sku set skuname = '{skuname}' where sku = '{sku}'")
#print(skuname)
for subtitle in subtitle_list:
value = row[subtitle].strip()
subtitleid = subtitle_id_dict[subtitle]
subtitle_type = subtitle_type_dict[subtitle]
if subtitle_type == 'sku':
cursor_zi_new.execute(f"select id from p_skuvalue where subtitleid = {subtitleid} and value = '{value}' order by id")
data = cursor_zi_new.fetchall()
try:
valueid = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])['id'].tolist()[0]
except:
cursor_zi_new.execute(f"insert into p_skuvalue (subtitleid,value) values ({subtitleid}, '{value}')")
cursor_zi_new.execute(f"select id from p_skuvalue where subtitleid = {subtitleid} and value = '{value}'")
valueid = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])['id'].tolist()[0]
cursor_zi_new.execute(f"select a.valueid from p_skuvaluemap a \
left join p_skuvalue b \
on a.valueid = b.id \
left join p_skusubtitle c \
on b.subtitleid = c.id \
where a.skuid = {skuid} and c.name = '{subtitle}'")
data = cursor_zi_new.fetchall()
valueid_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])
if valueid_df.empty:
cursor_zi_new.execute(f"select id from p_skuvaluemap where skuid = {skuid} and valueid = {valueid}")
data = cursor_zi_new.fetchall()
check_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])
if check_df.empty:
cursor_zi_new.execute(f"insert into p_skuvaluemap (skuid,valueid) values ({skuid}, {valueid})")
else:
valueid_list = valueid_df['valueid'].unique().tolist()
for valueid_ in valueid_list:
cursor_zi_new.execute(f"delete from p_skuvaluemap where skuid = {skuid} and valueid = {valueid_}")
cursor_zi_new.execute(f"select id from p_skuvaluemap where skuid = {skuid} and valueid = {valueid}")
data = cursor_zi_new.fetchall()
check_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])
if check_df.empty:
cursor_zi_new.execute(f"insert into p_skuvaluemap (skuid,valueid) values ({skuid}, {valueid})")
elif subtitle_type == 'spu':
cursor_zi_new.execute(f"select id from p_value where subtitleid = {subtitleid} and value = '{value}' order by id")
data = cursor_zi_new.fetchall()
try:
valueid = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])['id'].tolist()[0]
except:
cursor_zi_new.execute(f"insert into p_value (subtitleid,value) values ({subtitleid}, '{value}')")
cursor_zi_new.execute(f"select id from p_value where subtitleid = {subtitleid} and value = '{value}'")
valueid = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])['id'].tolist()[0]
cursor_zi_new.execute(f"select a.valueid from p_valuemap a \
left join p_value b \
on a.valueid = b.id \
left join p_subtitle c \
on b.subtitleid = c.id \
where a.spuid = {spuid} and c.name = '{subtitle}'")
data = cursor_zi_new.fetchall()
valueid_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])
if valueid_df.empty:
cursor_zi_new.execute(f"select id from p_valuemap where spuid = {spuid} and valueid = {valueid}")
data = cursor_zi_new.fetchall()
check_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])
if check_df.empty:
cursor_zi_new.execute(f"insert into p_valuemap (spuid,valueid) values ({spuid}, {valueid})")
else:
valueid_list = valueid_df['valueid'].unique().tolist()
for valueid_ in valueid_list:
cursor_zi_new.execute(f"delete from p_valuemap where spuid = {spuid} and valueid = {valueid_}")
cursor_zi_new.execute(f"select id from p_valuemap where spuid = {spuid} and valueid = {valueid}")
data = cursor_zi_new.fetchall()
check_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])
if check_df.empty:
cursor_zi_new.execute(f"insert into p_valuemap (spuid,valueid) values ({spuid}, {valueid})")
conn_zi_new.close()
print(f"{category_name}参数数据更新完成,命名完成")
category_name = ''
path = ''
upload_params_data(category_name,path)
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 24 15:07:58 2021
@author: rico
"""
import pandas as pd
import pymssql
from public import zgc_api
def check_data(category_name,path):
df = pd.read_excel(path,converters = {'产品编码':str})
df = df.rename(columns = {'Unnamed: 0':'id'})
if '无参数,需补充' in df.values:
print("仍有参数未补充,请补充完整后再继续处理。")
return False
#创建新产品库链接
conn_zi_new = pymssql.connect(host='123.56.115.207', user='zgcprice3311',password='zgcprice20200628',database= 'ZI_NEW',autocommit=True)
cursor_zi_new = conn_zi_new.cursor()
#进行非标转标
##加载库中参数项数据(参数id,参数从属)
cursor_zi_new.execute(f"select * from vw_property where name = '{category_name}'")
db_params = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])
db_params['standard_param'] = db_params['identy'].apply(lambda x: x[2])
db_params = db_params[db_params['standard_param'] != '0']
db_params['subtitle'] = db_params['subtitle'].apply(lambda x: x.strip())
#subtitle_id_list = dict(zip(db_params['subtitle'].tolist(),db_params['subtitleid'].tolist()))
#subtitle_type_list = dict(zip(db_params['subtitle'].tolist(),db_params['skuorspu'].tolist()))
params_list = df.columns.tolist()[-len(db_params['subtitle']):]
recover_params_list = [params[1:] for params in params_list]
rename_dict = dict(zip(params_list,recover_params_list))
df = df.rename(columns = rename_dict)
##数据准备
id_list = list()
params_list = list()
for index,row in df.iterrows():
id_ = row['id']
id_list.append(id_)
temp_key_list = list()
temp_value_list = list()
for db_param in db_params['subtitle'].tolist():
if db_param in ['产品型号', 'CPU属性']:
continue
temp_key_list.append(db_param)
temp_value_list.append(row[db_param])
params_list.append(dict(zip(temp_key_list, temp_value_list)))
print(f"{category_name}数据准备完成")
##获取标准参数值
data = {
"params_info": {
"category": category_name,
"id_list": id_list,
"params_dict_list": params_list
}
}
res = zgc_api("GetZGCParamValuesInfo", data)
res_value_dict = res['paramsValue_dict']
#非标准值添加数据字典
flag = False
dict_id_list = list()
for index,row in df.iterrows():
id_ = str(row['id'])
for db_param in db_params['subtitle'].tolist():
if db_param in ['产品型号', 'CPU属性']:#CPU属性为衍生属性,需要特殊处理
continue
pri_value = row[db_param]
value, value_flag = tuple(res_value_dict[id_][db_param].items())[0]
if value_flag == False:
cursor_zi_new.execute(f"select * from ShuJuZiDian_Cfg where categoryname = '{category_name}' and subtitle = '{db_param}' and primitive = '{pri_value}'")
check_df = pd.DataFrame(cursor_zi_new.fetchall(),
columns=[tuple[0] for tuple in cursor_zi_new.description])
if check_df.empty:
flag = True
cursor_zi_new.execute(f"insert into ShuJuZiDian_Cfg (categoryname,subtitle,primitive) values ('{category_name}','{db_param}','{pri_value}')")
cursor_zi_new.execute(f"select id from ShuJuZiDian_Cfg where categoryname = '{category_name}' and subtitle = '{db_param}' and primitive = '{pri_value}'")
dict_id = cursor_zi_new.fetchone()[0]
dict_id_list.append(dict_id)
if flag:
if len(dict_id_list) == 1:
_id = dict_id_list[0]
cursor_zi_new.execute(f"select * from ShuJuZiDian_Cfg where stdvalue is Null and id = {_id}")
else:
cursor_zi_new.execute("select * from ShuJuZiDian_Cfg where stdvalue is Null and id in (%s)" % ','.join(['%s'] * len(dict_id_list)),tuple(dict_id_list))
fill_shujuzidian_df = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])
fill_shujuzidian_df.to_excel(f"{category_name}数据字典补充.xlsx")
else:
for db_param in db_params['subtitle'].tolist():
if db_param == '产品型号':
continue
param_var = '_' + ''.join(db_param.split()).replace('(','').replace(')','').replace('/','').replace('(','').replace(')','').replace('+','').replace('-','').replace('*','').replace('.','')
exec('%s_list=[]'%param_var)
for index,row in df.iterrows():
id_ = str(row['id'])
for db_param in db_params['subtitle'].tolist():
param_var = '_' + ''.join(db_param.split()).replace('(','').replace(')','').replace('/','').replace('(','').replace(')','').replace('+','').replace('-','').replace('*','').replace('.','')
if db_param == '产品型号':
continue
elif db_param == 'CPU属性':
value,value_flag = tuple(res_value_dict[id_]['CPU型号'].items())[0]
if '飞腾' in value or '龙芯' in value or '兆芯' in value:
pass
else:
value = value.split('-')[0]
else:
value,value_flag = tuple(res_value_dict[id_][db_param].items())[0]
exec("%s_list.append('%s')"%(param_var,value))
for db_param in db_params['subtitle'].tolist():
if db_param == '产品型号':
continue
param_var = '_' + ''.join(db_param.split()).replace('(','').replace(')','').replace('/','').replace('(','').replace(')','').replace('+','').replace('-','').replace('*','').replace('.','')
exec("df['%s']=%s_list"%(db_param,param_var))
path = path.split('.xlsx')[0] + '(校验通过).xlsx'
df.to_excel(path,index=False)
print(f"{category_name}数据通过校验,可更新库内参数")
category_name = ''
path = ''
check_data(category_name,path)
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 to comment