Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lzzzzl
/
param_data
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a5a9057d
authored
Nov 10, 2020
by
lzzzzl
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新attr_values mongo处理
parent
a8f1faf6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
9 deletions
.gitignore
fun/param_data.py
param_task/db_attr_value_all.py
upload/param_mongo.py
.gitignore
View file @
a5a9057d
...
...
@@ -9,3 +9,6 @@ out
log
gen
/config/db_config.py
# Python files
Test.py
fun/param_data.py
View file @
a5a9057d
...
...
@@ -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
)
param_task/db_attr_value_all.py
View file @
a5a9057d
...
...
@@ -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
:
...
...
upload/param_mongo.py
View file @
a5a9057d
...
...
@@ -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
)
...
...
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