Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
中
中电中采
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZGC_INDEX
中电中采
Commits
9814a1a2
Commit
9814a1a2
authored
Mar 31, 2021
by
rico.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
28fb5005
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
44 deletions
+26
-44
模板建库func.py
模板建库func.py
+26
-44
No files found.
模板建库func.py
View file @
9814a1a2
...
...
@@ -461,7 +461,7 @@ def check_params_data(path):
cat_df
=
pd
.
read_excel
(
path
,
sheetname
=
f
"{point_category}参数数据"
,
converters
=
{
'productcode'
:
str
})
except
:
continue
#加载数据字典
cursor_zi_new
.
execute
(
f
"select subtitle,stdvalue,primitive,simplevalue from ShuJuZiDian_Cfg where categoryname = '{category}'"
)
data_dict
=
pd
.
DataFrame
(
cursor_zi_new
.
fetchall
(),
columns
=
[
tuple
[
0
]
for
tuple
in
cursor_zi_new
.
description
])
...
...
@@ -475,30 +475,23 @@ def check_params_data(path):
id_list
=
list
()
params_list
=
list
()
for
index
,
row
in
cat_df
.
iterrows
():
for
id_
in
cat_df
[
'id'
]
.
unique
()
.
tolist
():
try
:
print
(
index_
(
counter
,
len
(
cat_df
)
-
1
),
end
=
'
%
'
)
print
(
index_
(
counter
,
len
(
cat_df
[
'id'
]
.
unique
()
.
tolist
()
)
-
1
),
end
=
'
%
'
)
counter
+=
1
except
:
print
(
index_
(
counter
,
1
),
end
=
'
%
'
)
#if row['remark'] != 'nan' and row['remark'] != 'None':
# continue
id_list
.
append
(
id_
)
id_
=
row
[
'id'
]
category
=
row
[
'zi_subcategoryname'
]
single_df
=
cat_df
[
cat_df
[
'id'
]
==
id_
]
single_df
[
'filter'
]
=
[
'1'
if
'(*)'
in
param
else
'0'
for
param
in
single_df
[
'param'
]
.
tolist
()]
single_df
=
single_df
[
single_df
[
'filter'
]
==
'1'
]
id_list
.
append
(
id_
)
params_dict
=
dict
(
zip
(
single_df
[
'param'
]
.
apply
(
lambda
x
:
x
.
replace
(
"(*)"
,
""
))
.
tolist
(),
single_df
[
'value'
]
.
tolist
()))
params_list
.
append
(
params_dict
)
temp_key_list
=
list
()
temp_value_list
=
list
()
for
db_param
in
db_params
[
db_params
[
'name'
]
==
category
][
'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}数据准备完成"
)
...
...
@@ -511,51 +504,42 @@ def check_params_data(path):
#实例化进度条
index_
=
ProgressLine
()
counter
=
1
for
index
,
row
in
cat_df
.
iterrows
():
for
id_
in
res_value_dict
.
keys
():
try
:
print
(
index_
(
counter
,
len
(
cat_df
)
-
1
),
end
=
'
%
'
)
print
(
index_
(
counter
,
len
(
res_value_dict
)
-
1
),
end
=
'
%
'
)
counter
+=
1
except
:
print
(
index_
(
counter
,
1
),
end
=
'
%
'
)
single_df
=
cat_df
[
cat_df
[
'id'
]
==
id_
]
eg_brand_name
=
single_df
[
'zi_brandname'
]
.
tolist
()[
0
]
eg_product_name
=
single_df
[
'name'
]
.
tolist
()[
0
]
#if row['remark'] != 'nan' and row['remark'] != 'None':
# continue
id_
=
str
(
row
[
'id'
])
category
=
row
[
'zi_subcategoryname'
]
eg_brand_name
=
row
[
'zi_brandname'
]
eg_product_name
=
row
[
'name'
]
eg_product_url
=
row
[
'url'
]
for
db_param
in
db_params
[
db_params
[
'name'
]
==
category
][
'subtitle'
]
.
tolist
():
for
param
in
res_value_dict
[
id_
]
.
keys
():
if
db_param
in
[
'产品型号'
,
'CPU属性'
]:
continue
value
,
value_flag
=
tuple
(
res_value_dict
[
id_
][
param
]
.
items
())[
0
]
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}' and subtitle = '{db_param}' and primitive = '{pri_value}'"
)
cursor_zi_new
.
execute
(
f
"select * from ShuJuZiDian_Cfg where categoryname = '{category}' and subtitle = '{param}' and primitive = '{value}'"
)
check_df
=
pd
.
DataFrame
(
cursor_zi_new
.
fetchall
(),
columns
=
[
tuple
[
0
]
for
tuple
in
cursor_zi_new
.
description
])
if
check_df
.
empty
:
init_fraction
=
0
recommend_pri
=
''
for
dict_pri
in
data_dict
[
data_dict
[
'subtitle'
]
==
db_
param
][
'primitive'
]
.
unique
()
.
tolist
():
for
dict_pri
in
data_dict
[
data_dict
[
'subtitle'
]
==
param
][
'primitive'
]
.
unique
()
.
tolist
():
try
:
fraction_part1
=
similarity_cn
(
pri_
value
,
dict_pri
)
fraction_part1
=
similarity_cn
(
value
,
dict_pri
)
except
:
#print(f"无法比较 '{pri_value}'与 '{dict_pri}'")
#fraction = 0
fraction_part1
=
0
fraction_part2
=
similarity_en
(
pri_
value
,
dict_pri
)
fraction_part2
=
similarity_en
(
value
,
dict_pri
)
fraction
=
fraction_part1
*
0.5
+
fraction_part2
*
0.5
if
fraction
>
init_fraction
:
...
...
@@ -566,16 +550,14 @@ def check_params_data(path):
recommend_simplevalue
=
data_dict
[
data_dict
[
'primitive'
]
==
recommend_pri
][
'simplevalue'
]
.
tolist
()[
0
]
flag
=
False
cursor_zi_new
.
execute
(
f
"insert into ShuJuZiDian_Cfg (categoryname,subtitle,primitive,eg_brand_name,eg_product_name,eg_product_url,recommend_primitive,recommend_stdvalue,recommend_simplevalue)
\
values ('{category}','{db_param}','{pri_value}','{eg_brand_name}','{eg_product_name}','{eg_product_url}','{recommend_pri}','{recommend_stdvalue}','{recommend_simplevalue}')"
)
cursor_zi_new
.
execute
(
f
"select id from ShuJuZiDian_Cfg where categoryname = '{category}' and subtitle = '{db_param}' and primitive = '{pri_value}'"
)
dict_id
=
cursor_zi_new
.
fetchone
()[
0
]
complicated_data_dict_id_list
.
append
(
dict_id
)
print
(
f
"完成{category}参数校验"
)
if
flag
:
mssql
.
Close
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment