Commit 0315fcf9 by 岳巧源

migrate

parent 8f59f1ef
Showing with 38 additions and 4 deletions
...@@ -10,12 +10,46 @@ def migrate_from_lie_scm_order(): ...@@ -10,12 +10,46 @@ def migrate_from_lie_scm_order():
'db': "liexin_purchase", 'db': "liexin_purchase",
'charset': 'utf8' 'charset': 'utf8'
} }
sql1 = "select " #先获取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"
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
sql4 = "select purchase_sn, erp_purchase_sn, company_id, company_name from lie_purchase_order where purchase_id = "
db = pymysql.connect(**conf) db = pymysql.connect(**conf)
cursor = db.cursor() cursor = db.cursor()
cursor.execute(sql1) cursor.execute(sql1)
result1 = cursor.fetchall() result1 = cursor.fetchall() #sql的执行结果
for row in result1:
source_type = 2 #---------------------------
source_id = row[0] #------------------------
purchase_id = row[2]
purchase_item_id = str(row[1])
tmp_sql2 = sql2 + purchase_item_id
cursor.execute(tmp_sql2)
result2 = cursor.fetchall() #第二条sql的执行结果
if len(result2) == 0:
continue
frq_id = result2[0][0]
tmp_sql3 = sql3 + str(frq_id)
cursor.execute(tmp_sql3)
result3 = cursor.fetchall()
if len(result3) == 0:
continue
erp_sn = result3[0][0]
kingdee_sales_order_no = str(erp_sn) #------------------------
tmp_sql4 = sql4 + str(purchase_id)
cursor.execute(tmp_sql4)
result4 = cursor.fetchall()
if len(result4) == 0:
continue
purchase_sn = result4[0][0] #-------------------------------
erp_purchase_sn = result4[0][1]
kingdee_purchase_order_no = erp_purchase_sn #--------------------------------
company_id = result4[0][2] #---------------------------
company_name = result4[0][3] #---------------------------
if __name__ == '__main__': if __name__ == '__main__':
pass migrate_from_lie_scm_order()
\ No newline at end of file \ No newline at end of file
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 sign in to comment