Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
matchSKUWithDB
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
matchSKUWithDB
Commits
04f40546
Commit
04f40546
authored
Jan 19, 2020
by
rico.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
831e6dcf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
62 deletions
+89
-62
matchSKU.py
matchSKU.py
+89
-62
No files found.
matchSKU.py
View file @
04f40546
...
...
@@ -19,15 +19,42 @@ def matchSKU(sku_list,frm):
cursor
=
conn
.
cursor
()
print
(
'正在删除库中产品状态为6的sku,稍等。。。'
)
#首先将库中错误状态产品的JD/SN/GM的SKU删除
cursor
.
execute
(
"DELETE from productcode_sku where productcode in (select productcode from info_product where state='6')"
)
print
(
'正在删除库中重复的SKU,稍等。。。'
)
#需先删除库中重复的SKU,避免匹配相同的编码
cursor
.
execute
(
"declare OperCursor Cursor for
\
SELECT productcode,sku,frm,count(*) ca FROM productcode_sku
\
GROUP BY productcode,sku,frm
\
HAVING COUNT(*)>1
\
open OperCursor
\
declare @PRODUCTCODE as nvarchar(20)
\
declare @sku as nvarchar(50)
\
declare @frm as nvarchar(20)
\
declare @ca as int
\
declare @return_value as int
\
fetch next from OperCursor into @PRODUCTCODE,@sku,@frm,@ca
\
IF @@fetch_status=0
\
delete from productcode_sku
\
where id in (select top (@ca-1) id from productcode_sku
\
where productcode=@PRODUCTCODE and sku=@sku and frm=@frm)
\
\
while @@fetch_status=0
\
begin
\
fetch next from OperCursor into @PRODUCTCODE,@sku,@frm,@ca
\
IF @@fetch_status=0
\
delete from productcode_sku
\
where id in (select top (@ca-1) id from productcode_sku
\
where productcode=@PRODUCTCODE and sku=@sku and frm=@frm)
\
end
\
close OperCursor
\
deallocate OperCursor"
)
conn
.
commit
()
print
(
'正在获取当前库中所有sku,请稍等.....'
)
#获取库中所有的SKU,以供检查
try
:
get_all_sku
=
f
"select * from productcode_sku where frm in {frm}
"
get_all_sku
=
f
"select * from productcode_sku where frm in {frm}
and productcode not like '78
%
' "
cursor
.
execute
(
get_all_sku
)
data_sku
=
(
cursor
.
fetchall
())
data_sku_file
=
pd
.
DataFrame
(
data_sku
,
columns
=
[
'id'
,
'productcode'
,
'sku'
,
'skuname'
,
'createddate'
,
'frm'
])
except
:
get_all_sku
=
f
"select * from productcode_sku where frm='{frm}'
"
get_all_sku
=
f
"select * from productcode_sku where frm='{frm}'
and productcode not like '78
%
' "
cursor
.
execute
(
get_all_sku
)
data_sku
=
(
cursor
.
fetchall
())
data_sku_file
=
pd
.
DataFrame
(
data_sku
,
columns
=
[
'id'
,
'productcode'
,
'sku'
,
'skuname'
,
'createddate'
,
'frm'
])
...
...
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