import queue
import pandas as pd
import requests
import os
import time
import json
import urllib3
import warnings
from queue import Queue
from threading import Thread
from datetime import date, timedelta, datetime
from fake_useragent import UserAgent
from selenium import webdriver
from positionB_mysql_models import *
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ua = UserAgent()
today = date.today()
begin_day = today - timedelta(weeks=4)
que_return_complete = Queue()
que_return_record = Queue()
class LoginIn(object):
def get_cookies(self):
chromeOptions = webdriver.ChromeOptions()
prefs = {'download.default_directory': BASE_DIR}
chromeOptions.add_experimental_option('prefs', prefs)
chromeOptions.page_load_strategy = 'eager'
driver = webdriver.Chrome(chrome_options=chromeOptions)
driver.implicitly_wait(20)
page_url = 'https://agx.sfwl.net/login/?url=http://xtms.sfwl.net/Main.htm'
driver.get(page_url)
driver.maximize_window()
time.sleep(30)
cookies = driver.get_cookies()
json_cookie = json.dumps(cookies)
return driver, json_cookie
def login(self, driver, json_cookie):
request = requests.Session()
cookies = json.loads(json_cookie)
for cookie in cookies:
request.cookies.set(cookie['name'], cookie['value'])
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
driver.close()
return driver, request
def run(self):
warnings.filterwarnings('ignore')
driver, json_cookie = self.get_cookies()
driver, request = self.login(driver, json_cookie)
return driver, request
class ReturnablePackaging(object):
# 特斯拉反空登记 输入单号查询
def ship_query_information(self, request, ship_no):
headers = {"User-Agent": ua.random,
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Connection": "keep-alive",
"Content-Length": "600",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Host": "xtms.sfwl.net",
"Origin": "https://xtms.sfwl.net",
"Referer": "https://xtms.sfwl.net/TRAN/Order/OrderTesla.htm?r=0.058275188852138005",
"sec-ch-ua": '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "macOS",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"X-Requested-With": "XMLHttpRequest"}
url = "https://xtms.sfwl.net/Data/Tran/OrderTesla.ashx"
data = {
"tran_org": "特斯拉项目部",
"tran_comid": "970f06a4-9d81-4c04-a0b2-5eb1fd365577",
"tran_subId": "6aaed10f-fd48-47dd-a5b8-0afb11248481",
"select_Time_Condition": "odd_addtime",
"date_begin": begin_day,
"date_end": today,
"select_Condition": "OMS_Waybill.way_print_sn",
"select_Value": "",
"select_Condition2": "OMS_Waybill.way_print_sn",
"select_Value2": ship_no,
"waytstate": "",
"isDisabled": "0",
"movement": "Get_OrderTesla_List",
"random": "0.20508905538816258",
"page": "1",
"rows": "20"}
res = request.post(url, headers=headers, data=data)
ship_query_information_json_dict = json.loads(res.text)
return ship_query_information_json_dict
# 输入箱号查询 最新的正向提货信息
def pick_up_new_dtocNumber(self, request, dtocNumber):
headers = {"User-Agent": ua.random,
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '63',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'xtms.sfwl.net',
'Origin': 'https://xtms.sfwl.net',
'Referer': 'https://xtms.sfwl.net/TRAN/Order/OrderTesla.htm?r=0.5218068645960179',
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': "macOS",
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'X-Requested-With': 'XMLHttpRequest'}
url = "https://xtms.sfwl.net/Data/Tran/OrderTesla.ashx"
data = {'movement': 'Get_OrderTesla_TrailerNumber',
'trailerNumber': dtocNumber}
res = request.post(url, headers=headers, data=data)
pick_up_new_dtocNumber_json_dict = json.loads(res.text)
return pick_up_new_dtocNumber_json_dict
# 电子围栏查询操作
def electronic_fence(self, request, ship_no):
url = 'https://xtms.sfwl.net/Data/Tran/DXI_Tesla_OrderReject.ashx'
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '600',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'xtms.sfwl.net',
'Origin': 'https://xtms.sfwl.net',
'Referer': 'https://xtms.sfwl.net/TRAN/Order/OrderTesla_TranNode.htm?r=0.5744174438654963',
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': "macOS",
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'X-Requested-With': 'XMLHttpRequest',
"User-Agent": ua.random}
data = {
'tran_org': '',
'way_comId': '970F06A4-9D81-4C04-A0B2-5EB1FD365577',
'way_subId': '6AAED10F-FD48-47DD-A5B8-0AFB11248481',
'select_Time_Condition': 'way_addTime',
'date_begin': begin_day,
'date_end': today,
'way_isforward': '',
'textType': 'way_print_sn',
'textValue': '',
'textType1': 'way_print_sn',
'textValue1': ship_no,
'signinStatus': '',
'sort': 'dtoc_sendTime',
'movement': 'GET_OrderTeslaTranNode_List',
'page': '1',
'rows': '20'}
res = request.post(url, headers=headers, data=data)
electronic_fence_json_dict = json.loads(res.text)
return electronic_fence_json_dict
# 反空回单操作 已完成
def returnable_complete(self, request, ship_query_information_json_dict, electronic_fence_json_dict):
way_id = ship_query_information_json_dict['rows'][0].get('way_id')
way_print_sn = ship_query_information_json_dict['rows'][0].get('way_print_sn')
wayt_addtime = ship_query_information_json_dict['rows'][0].get('wayt_addtime')
way_jhtime = ship_query_information_json_dict['rows'][0].get('way_jhtime')
wayt_planBackTime = ship_query_information_json_dict['rows'][0].get('wayt_planBackTime')
wayt_actionTime = ship_query_information_json_dict['rows'][0].get('wayt_actionTime') # 此处需要后期完善
wayt_askArrTime = ship_query_information_json_dict['rows'][0].get('wayt_askArrTime')
wayt_actionArrTime = electronic_fence_json_dict['rows'][0].get('actualArrivalTime')
if not wayt_actionArrTime:
load_SendSysTime = electronic_fence_json_dict['rows'][0].get('load_SendSysTime')
wayt_actionArrTime = datetime.strptime(load_SendSysTime, "%Y-%m-%d %H:%M:%S") + timedelta(hours=3)
wayt_trailerNumber = ship_query_information_json_dict['rows'][0].get('wayt_trailerNumber')
wayt_sealSn = ship_query_information_json_dict['rows'][0].get('wayt_sealSn')
wayt_guacarnumber = ship_query_information_json_dict['rows'][0].get('wayt_guacarnumber')
wayt_dirname = ship_query_information_json_dict['rows'][0].get('wayt_dirname')
wayt_carnumber = ship_query_information_json_dict['rows'][0].get('wayt_carnumber')
url = 'https://xtms.sfwl.net/Data/Tran/OrderTesla.ashx'
headers = {
"User-Agent": ua.random,
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '600',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'xtms.sfwl.net',
'Origin': 'https://xtms.sfwl.net',
'Referer': 'https://xtms.sfwl.net/TRAN/Order/OrderTesla.htm?r=0.5218068645960179',
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': "macOS",
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
}
data = {
'way_id': way_id,
'ord_id': '',
'wayt_state': '2',
'wayt_addtime': wayt_addtime,
'way_jhtime': way_jhtime,
'wayt_hour': '24',
'wayt_planBackTime': wayt_planBackTime,
'wayt_actionTime': wayt_actionTime,
'wayt_askArrTime': wayt_askArrTime,
'wayt_actionArrTime': wayt_actionArrTime,
'wayt_trailerNumber': wayt_trailerNumber,
'wayt_sealSn': wayt_sealSn,
'wayt_guacarnumber': wayt_guacarnumber,
'wayt_dirname': wayt_dirname,
'wayt_carnumber': wayt_carnumber,
'wayt_tccdirname': '',
'wayt_arrtcctime': '',
'subId': '6aaed10f-fd48-47dd-a5b8-0afb11248481',
'movement': 'Set_OrderTesla_ExtendInfo'}
res = request.post(url, headers=headers, data=data)
json_data = json.loads(res.text)
if json_data['State'] == True:
ft = ReturnComplete.update(complete_time=wayt_actionArrTime).where(ReturnComplete.ship_no == way_print_sn)
ft.execute()
ft = ReturnComplete.update(remark='已完成').where(ReturnComplete.ship_no == way_print_sn)
ft.execute()
# 按照箱号查 没有录过 的反空单号,日期范围(单据日期,单据日期+1)
def search_order_number(self, dtocNumber, date):
url = 'https://xtms.sfwl.net/jtms/transport/tesla/TeslaOrderChangeInfoController/queryTeslaOrderChangeInfo'
headers = {
"User-Agent": ua.random,
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '500',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'xtms.sfwl.net',
'Origin': 'https://xtms.sfwl.net',
'Referer': 'https://xtms.sfwl.net/jtms/transport/tesla/TeslaOrderChangeInfoController/toTeslaOrderChangeInfoPage?r=0.13049012867511278',
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': "macOS",
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'X-Requested-With': 'XMLHttpRequest'}
data = {
'timeType': 'dtoc_getTime',
'startTime': date,
'endTime': date + timedelta(days=1),
'isAssociated': '1',
'changeCountType': '>=',
'dtocNumber': dtocNumber,
'sourceType': 'ReturnablePackaging',
'random': '0.5867127487088089',
'page': '1',
'rows': '20'}
res = request.post(url, headers=headers, data=data)
search_order_number_json_dict = json.loads(res.text)
return search_order_number_json_dict
# 特斯拉反空登记 录单数据存入mysql
def returnable_record_mysql(self):
df = pd.read_excel('反空录单.xlsx')
length_df = len(df)
df_dict_new = []
for index in range(0, length_df):
df_dict = list(df.iloc[index])
df_dict_new.append(df_dict[:])
for i in range(length_df):
dtocNumber = ''
date = ''
doc_supplier_code = ''
doc_supplier = ''
last_delivery_supplier_code = ''
last_delivery_supplier = ''
returnable_ship_no = ''
returnable_supplier_code = ''
returnable_supplier = ''
try:
dtocNumber = df_dict_new[i][0].split('_')[0]
pick_up_new_dtocNumber_json_dict = self.pick_up_new_dtocNumber(request, dtocNumber)
date1 = df_dict_new[i][0].split('_')[1]
date = datetime(int(date1[0:4]), int(date1[4:6]), int(date1[6:8]))
search_order_number_json_dict = self.search_order_number(dtocNumber, date)
doc_supplier_code = df_dict_new[i][0].split('_')[2]
if (doc_supplier_code == '161095') and ("下壳" in str(df_dict_new[i][1])):
doc_supplier_code = '金桥161095'
doc_supplier = SupplierCodePrice.get(
SupplierCodePrice.supplier_code == doc_supplier_code).chinese_supplier
last_delivery_supplier_code = pick_up_new_dtocNumber_json_dict[0].get('way_arrivecompany_sn')
last_delivery_supplier = pick_up_new_dtocNumber_json_dict[0].get('way_clicompany_arrive')
if search_order_number_json_dict['total'] == 1:
returnable_ship_no = search_order_number_json_dict['rows'][0].get('orderSn')
returnable_supplier_name = search_order_number_json_dict['rows'][0].get('arriveCom')
returnable_supplier_code = SupplierCodePrice.get(
SupplierCodePrice.english_supplier == returnable_supplier_name).supplier_code
returnable_supplier = SupplierCodePrice.get(
SupplierCodePrice.supplier_code == returnable_supplier_code).chinese_supplier
remark = '可以录单'
que_return_record.put(df_dict_new[i][0])
elif search_order_number_json_dict['total'] > 1:
returnable_ship_no = ''
returnable_supplier_code = ''
returnable_supplier = ''
remark = '推送多个反空单号'
elif search_order_number_json_dict['total'] == 0:
returnable_ship_no = ''
returnable_supplier_code = ''
returnable_supplier = ''
remark = '没有推送单号或单号已录过'
except:
remark = '单据类型错误'
if (doc_supplier_code == '164151') and ('27' in str(df_dict_new[i][1])):
doc_supplier = '拓普三部'
elif (doc_supplier_code == '164151') and ('28' in str(df_dict_new[i][1])):
doc_supplier = '拓普三部'
data = {
"scanning_code": df_dict_new[i][0],
"part_no": df_dict_new[i][1],
"sealsn": df_dict_new[i][2],
"dtocNumber": dtocNumber,
"date": date,
'doc_supplier_code': doc_supplier_code,
"doc_supplier": doc_supplier,
"last_delivery_supplier_code": last_delivery_supplier_code,
'last_delivery_supplier': last_delivery_supplier,
"returnable_ship_no": returnable_ship_no,
"returnable_supplier_code": returnable_supplier_code,
'returnable_supplier': returnable_supplier,
'remark': remark}
tk = ReturnRecord.select().where(ReturnRecord.scanning_code == df_dict_new[i][0])
if not tk:
record = ReturnRecord(**data)
record.save()
else:
record = ReturnRecord.update(**data).where(ReturnRecord.scanning_code == df_dict_new[i][0])
record.execute()
# 录单开始函数
def run_returnable_record(self, request, que_return_record):
shaoma = que_return_record.get(timeout=2)
if len(shaoma.split('_')) == 4:
doc_supplier_code = ReturnRecord.get(ReturnRecord.scanning_code == shaoma).doc_supplier_code
returnable_supplier_code = ReturnRecord.get(
ReturnRecord.scanning_code == shaoma).returnable_supplier_code
if doc_supplier_code == returnable_supplier_code:
last_delivery_supplier_code = ReturnRecord.get(
ReturnRecord.scanning_code == shaoma).last_delivery_supplier_code
date1 = shaoma.split('_')[1]
date = datetime(int(date1[0:4]), int(date1[4:6]), int(date1[6:8]))
dtocNumber = ReturnRecord.get(ReturnRecord.scanning_code == shaoma).dtocNumber
search_order_number_json_dict = self.search_order_number(dtocNumber, date)
pick_up_new_dtocNumber_json_dict = self.pick_up_new_dtocNumber(request, dtocNumber)
if search_order_number_json_dict['total'] == 1:
url = 'https://xtms.sfwl.net/Data/Tran/OrderTesla.ashx'
headers = {'Accept': '*/*',
"User-Agent": ua.random,
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '2000',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'xtms.sfwl.net',
'Origin': 'https://xtms.sfwl.net',
'Referer': 'https://xtms.sfwl.net/TRAN/Order/OrderTesla.htm?r=0.5218068645960179',
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': "macOS",
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'X-Requested-With': 'XMLHttpRequest'}
way_clicompany_arrive = ReturnRecord.get(ReturnRecord.scanning_code == shaoma).doc_supplier
way_print_sn = ReturnRecord.get(ReturnRecord.scanning_code == shaoma).returnable_ship_no
sealSn = ReturnRecord.get(ReturnRecord.scanning_code == shaoma).sealsn
way_jhtime = search_order_number_json_dict['rows'][0]['requiredTime']
way_yunRmb = SupplierCodePrice.get(
SupplierCodePrice.chinese_supplier == way_clicompany_arrive).price
part_no = ReturnRecord.get(ReturnRecord.scanning_code == shaoma).part_no
way_clitel_arrive = SupplierBasicData.get(
SupplierBasicData.way_clicompany_arrive == way_clicompany_arrive).way_clitel_arrive
way_cityName = SupplierBasicData.get(
SupplierBasicData.way_clicompany_arrive == way_clicompany_arrive).way_cityName
way_EndCityName = SupplierBasicData.get(
SupplierBasicData.way_clicompany_arrive == way_clicompany_arrive).way_EndCityName
way_cityId = SupplierBasicData.get(
SupplierBasicData.way_clicompany_arrive == way_clicompany_arrive).way_cityId
way_EndCityid = SupplierBasicData.get(
SupplierBasicData.way_clicompany_arrive == way_clicompany_arrive).way_EndCityid
way_cliaddress_arrive = SupplierBasicData.get(
SupplierBasicData.way_clicompany_arrive == way_clicompany_arrive).way_cliaddress_arrive
way_other = pick_up_new_dtocNumber_json_dict[0]['way_other']
wayt_guacarnumber = pick_up_new_dtocNumber_json_dict[0]['guaNumber']
data = {'wayt_trailerNumber': dtocNumber,
'way_print_sn': way_print_sn,
'way_subId': '6aaed10f-fd48-47dd-a5b8-0afb11248481',
'way_comid': '970f06a4-9d81-4c04-a0b2-5eb1fd365577',
'wayt_sealSn': sealSn,
'wayt_addtime': today,
'way_jhtime': way_jhtime,
'wayt_askArrTime': '',
'way_yunRmb': way_yunRmb,
'way_arrivecompany_sn': doc_supplier_code,
'way_billType': '',
'way_partNo': part_no,
'way_clicompany_send': '特斯拉(上海)有限公司',
'way_cliId_send': '55f70cbf-9249-4ec2-a593-b3f1384e15a1',
'way_cliperid_send': '4782a230-c1d0-4ec2-b1ea-46c29f9a2735',
'way_SalePerid': '80eb8d4d-bfb7-4267-8ecf-cfc0cb5ce09e',
'way_cliname_send': 'TY',
'way_clitel_send': 'TY',
'way_cliphone_send': '',
'way_BeginCityName': '泥城镇',
'way_BeginCityid': '7675fb02-d6c9-4ee3-82e9-9d86b6171c40',
'way_cliaddress_send': '上海浦东新区正嘉路',
'way_clicompany_arrive': way_clicompany_arrive,
'way_cliname_arrive': way_clicompany_arrive,
'way_clitel_arrive': way_clitel_arrive,
'way_cliphone_arrive': '',
'way_cityName': way_cityName,
'way_EndCityName': way_EndCityName,
'way_cityId': way_cityId,
'way_EndCityid': way_EndCityid,
'way_cliaddress_arrive': way_cliaddress_arrive,
'way_nameSum': '料架',
'way_pack': 'tuopan',
'way_numSum': '1',
'way_wtSum': '2000.00',
'way_volSum': '50.00',
'way_other': way_other,
'way_RemarkHD': '',
'wayt_guacarnumber': wayt_guacarnumber,
'way_gooyunRmb': way_yunRmb,
'way_oweRmb': way_yunRmb,
'movement': 'Set_OrderTesla_AddBackWaybill'}
res = request.post(url, headers=headers, data=data)
res_json = json.loads(res.text)
if res_json['State'] == True:
if last_delivery_supplier_code == doc_supplier_code:
ft = ReturnRecord.update(remark='录单完成').where(
ReturnRecord.scanning_code == shaoma)
ft.execute()
ft = ReturnRecord.update(record_time=datetime.now()).where(
ReturnRecord.scanning_code == shaoma)
ft.execute()
elif last_delivery_supplier_code != doc_supplier_code:
ft = ReturnRecord.update(remark='录单完成,本次与上次供应商不一致').where(
ReturnRecord.scanning_code == shaoma)
ft.execute()
ft = ReturnRecord.update(record_time=datetime.now()).where(
ReturnRecord.scanning_code == shaoma)
ft.execute()
# 将需要操作已完成的单号存入mysql
def returnable_complete_mysql(self):
df = pd.read_excel('回单已完成单号.xlsx', header=0)
ship_nos = df['单号'].tolist()
for ship in ship_nos:
complete_ft = ReturnComplete()
que_return_complete.put(ship)
tests = ReturnComplete.select().where(ReturnComplete.ship_no == ship)
if not tests:
complete_ft.ship_no = ship
complete_ft.save()
# 回单操作已完成 开始接口
def run_returnable_complete(self, request, que_return_complete):
while True:
try:
ship_no = que_return_complete.get(timeout=2)
ship_query_information_json_dict = self.ship_query_information(request, ship_no)
electronic_fence_json_dict = self.electronic_fence(request, ship_no)
self.returnable_complete(request, ship_query_information_json_dict, electronic_fence_json_dict)
except queue.Empty:
time.sleep(1)
break
if __name__ == '__main__':
login_in = LoginIn()
driver, request = login_in.run()
returnable_packaging = ReturnablePackaging()
while True:
input1 = input("1:反空操作已完成 2:反空录单:")
if input1 == '1':
returnable_packaging.returnable_complete_mysql()
for t in ['t1', 't2', 't3', 't4', 't5', 't6']:
t = Thread(target=returnable_packaging.run_returnable_complete, args=(request, que_return_complete))
t.start()
if input1 == '2':
returnable_packaging.returnable_record_mysql()
while True:
try:
returnable_packaging.run_returnable_record(request, que_return_record)
except queue.Empty:
time.sleep(1)
break
from peewee import *
db = MySQLDatabase('PositionB', user='root', host='localhost', password=password, port=3306)
class BaseModel(Model):
class Meta:
database = db
class SupplierBasicData(BaseModel):
way_clicompany_arrive = CharField(primary_key=True)
way_clitel_arrive = CharField()
way_cityId = CharField()
way_cityName = CharField()
way_EndCityid = CharField()
way_EndCityName = CharField()
city_FullName = CharField()
way_cliaddress_arrive = CharField()
class Meta:
table_name = 'supplierbasicdata'
class SupplierCodePrice(BaseModel):
english_supplier = CharField()
chinese_supplier = CharField(primary_key=True)
supplier_code = CharField()
price = FloatField()
class Meta:
table_name = 'suppliercodeprice'
class ReturnRecord(BaseModel):
scanning_code = CharField()
part_no = CharField()
sealsn = CharField()
dtocNumber = CharField(null=True)
date = DateField(null=True)
doc_supplier_code = CharField(null=True)
doc_supplier = CharField(null=True)
last_delivery_supplier_code = CharField(null=True)
last_delivery_supplier = CharField(null=True)
returnable_ship_no = CharField(null=True)
returnable_supplier_code = CharField(null=True)
returnable_supplier = CharField(null=True)
remark = CharField(null=True)
record_time = DateTimeField(null=True)
class Meta:
table_name = 'returnrecord'
class ReturnComplete(BaseModel):
ship_no = CharField()
complete_time = CharField()
remark = CharField()
class Meta:
table_name = 'returncomplete'
def create_table(table):
if not table.table_exists():
table.create_table()
def drop_table(table):
if table.table_exists():
table.drop_table()
if __name__ == '__main__':
create_table(SupplierBasicData)
create_table(SupplierCodePrice)
create_table(ReturnRecord)
create_table(ReturnComplete)