Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
my-awesome-project
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
a5fcf3de
authored
Jun 28, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
connect sql
parent
0315fcf9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
5 deletions
migrate.py
migrate.py
View file @
a5fcf3de
import
pymysql
import
pymysql
item
=
[
"source_type"
,
"source_id"
,
"kingdee_sales_order_no"
,
"purchase_sn"
,
"kingdee_purchase_order_no"
,
"goods_id"
,
"goods_sn"
,
"goods_name"
,
"brand_id"
,
"brand_name"
,
"company_id"
,
"company_name"
,
"supplier_id"
,
"supplier_name"
,
"warehouse_receipt_sn"
,
"in_qty"
,
"out_qty"
,
"stock_in_status"
,
"create_name"
,
"shipping_id"
,
"create_uid"
,
"shipment_number"
,
"shipping_name"
,
"create_time"
,
"update_time"
,
"purchase_uid"
,
"purchase_name"
]
item_str
=
""
separator
=
", "
for
i
in
range
(
len
(
item
)):
if
i
!=
len
(
item
)
-
1
:
item_str
=
item_str
+
item
[
i
]
+
separator
else
:
item_str
=
item_str
+
item
[
i
]
def
migrate_from_lie_scm_order
():
def
migrate_from_lie_scm_order
():
conf
=
{
conf
=
{
...
@@ -11,7 +25,7 @@ def migrate_from_lie_scm_order():
...
@@ -11,7 +25,7 @@ def migrate_from_lie_scm_order():
'charset'
:
'utf8'
'charset'
:
'utf8'
}
}
#先获取scm的主键还有 purchase_item_id
#先获取scm的主键还有 purchase_item_id
sql1
=
"select scm_order_item_id, purchase_item_id, purchase_id, goods_id, goods_sn, goods_name, brand_id, brand_name from lie_scm_order"
sql1
=
"select scm_order_item_id, purchase_item_id, purchase_id, goods_id, goods_sn, goods_name, brand_id, brand_name
, supplier_id, supplier_name, warehouse_receipt_sn, in_qty, goods_number, stock_in_status, create_name, shipping_id, create_uid, shipment_number, shipping_name, create_time, update_time, purchase_uid, purchase_name
from lie_scm_order"
sql2
=
"select frq_id from lie_purchase_items where purchase_item_id = "
sql2
=
"select frq_id from lie_purchase_items where purchase_item_id = "
sql3
=
"select erp_sn from lie_frq where frq_id = "
#获取到的erp_sn作为 kingdee_sales_order_no
sql3
=
"select erp_sn from lie_frq where frq_id = "
#获取到的erp_sn作为 kingdee_sales_order_no
sql4
=
"select purchase_sn, erp_purchase_sn, company_id, company_name from lie_purchase_order where purchase_id = "
sql4
=
"select purchase_sn, erp_purchase_sn, company_id, company_name from lie_purchase_order where purchase_id = "
...
@@ -47,9 +61,50 @@ def migrate_from_lie_scm_order():
...
@@ -47,9 +61,50 @@ def migrate_from_lie_scm_order():
kingdee_purchase_order_no
=
erp_purchase_sn
#--------------------------------
kingdee_purchase_order_no
=
erp_purchase_sn
#--------------------------------
company_id
=
result4
[
0
][
2
]
#---------------------------
company_id
=
result4
[
0
][
2
]
#---------------------------
company_name
=
result4
[
0
][
3
]
#---------------------------
company_name
=
result4
[
0
][
3
]
#---------------------------
goods_id
=
row
[
3
]
#-----------------------
goods_sn
=
row
[
4
]
#-----------------------
goods_name
=
row
[
5
]
#---------------------
brand_id
=
row
[
6
]
#---------------------
brand_name
=
row
[
7
]
#---------------------
supplier_id
=
row
[
8
]
#-------------------
supplier_name
=
row
[
9
]
#-----------------
warehouse_receipt_sn
=
row
[
10
]
#------------
in_qty
=
row
[
11
]
#------------------
out_qty
=
row
[
12
]
#---------------
stock_in_status
=
row
[
13
]
#-----------------
create_name
=
row
[
14
]
shipping_id
=
row
[
15
]
create_uid
=
row
[
16
]
shipment_number
=
row
[
17
]
shipping_name
=
row
[
18
]
create_time
=
row
[
19
]
update_time
=
row
[
20
]
purchase_uid
=
row
[
21
]
purchase_name
=
row
[
22
]
value_arr
=
[
source_type
,
source_id
,
kingdee_sales_order_no
,
purchase_sn
,
kingdee_purchase_order_no
,
goods_id
,
goods_sn
,
goods_name
,
brand_id
,
brand_name
,
company_id
,
company_name
,
supplier_id
,
supplier_name
,
warehouse_receipt_sn
,
in_qty
,
out_qty
,
stock_in_status
,
create_name
,
shipping_id
,
create_uid
,
shipment_number
,
shipping_name
,
create_time
,
update_time
,
purchase_uid
,
purchase_name
]
value_str
=
""
for
i
in
range
(
len
(
value_arr
)):
if
i
!=
len
(
value_arr
)
-
1
:
if
len
(
str
(
value_arr
[
i
]))
==
0
:
value_str
=
value_str
+
"''"
+
", "
continue
value_str
=
value_str
+
str
(
value_arr
[
i
])
+
", "
else
:
if
len
(
str
(
value_arr
[
i
]))
==
0
:
value_str
=
value_str
+
"''"
continue
value_str
=
value_str
+
str
(
value_arr
[
i
])
insert_sql
=
"insert into lie_shipping_intermediate_data ("
+
item_str
+
") "
+
"values ("
+
value_str
+
")"
print
(
insert_sql
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
migrate_from_lie_scm_order
()
migrate_from_lie_scm_order
()
\ No newline at end of file
#migrate_from_lie_scm_order()
\ No newline at end of file
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