class ProductOutDao: def __init__(self): self.com_db = CommonDao() def get_iphone_info(self, table_name, IEMI): try: sql = "SELECT istorage, color, grade FROM trillion.%s WHERE IEMI=%s AND bstorage='1';" % (table_name, IEMI) iphone_info = CommonDao.search_option(self, sql) return iphone_info except: pass def get_iphone_type(self): try: sql = "SELECT iphonetype FROM trillion.iphonetype;" iphone_type = CommonDao.search_option(self, sql) if isinstance(iphone_type, list): return iphone_type else: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type except: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type def insert_sell_info(self, values): try: sql = "UPDATE trillion.%s SET " \ "outtime=CURRENT_TIMESTAMP, selller='%s', bstorage='%s', tocompany='%s', tracknumber='%s', salenumber='%s', remarks='%s' WHERE IEMI='%s';" % values # print(sql) results = CommonDao.change_option(self, sql) print(results) return results except: pass
class ClassificationDao: def __init__(self): self.com_db = CommonDao() def get_iphone_type(self): try: sql = "SELECT iphonetype FROM trillion.iphonetype;" iphone_type = CommonDao.search_option(self, sql) if isinstance(iphone_type, list): return iphone_type else: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type except: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type def get_iphone_info(self, table_name, IEMI): try: sql = "SELECT IEMI, istorage, color, productlines FROM trillion.%s WHERE IEMI=%s and bstorage='1';" % ( table_name, IEMI) iphone_info = CommonDao.search_option(self, sql) return iphone_info except: pass def submit_class(self, values): try: sql = "UPDATE trillion.%s SET " \ "grade='%s', remarks='%s' WHERE IEMI='%s';" % values # print(sql) iphone_info = CommonDao.change_option(self, sql) return iphone_info except: pass
class InventoryDao: def __init__(self): self.com_db = CommonDao() def get_product_lines(self): try: sql = "SELECT productlines FROM trillion.productlines;" product_lines = CommonDao.search_option(self, sql) if isinstance(product_lines, list): return product_lines else: product_lines = self.com_db.get_local_data("productlines") return product_lines except: product_lines = self.com_db.get_local_data("productlines") return product_lines def get_iphone_info(self, table_name, IEMI): try: sql = "SELECT productlines, istorage, color, bstorage FROM trillion.%s WHERE IEMI=%s;" % (table_name, IEMI) iphone_info = CommonDao.search_option(self, sql) return iphone_info except: pass def get_iphone_type(self): try: sql = "SELECT iphonetype FROM trillion.iphonetype;" iphone_type = CommonDao.search_option(self, sql) if isinstance(iphone_type, list): return iphone_type else: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type except: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type def get_iphone_info_theory(self, table_name, product_line): try: sql = f"SELECT productlines, istorage, color FROM trillion.{table_name} WHERE productlines='{product_line}' and bstorage='1';" iphone_info = CommonDao.search_option(self, sql) return iphone_info except: pass def get_iphone_info_actual(self, table_name, product_line): try: sql = f"SELECT productlines, istorage, color FROM trillion.{table_name} WHERE productlines='{product_line}' and forinventory='1';" iphone_info = CommonDao.search_option(self, sql) return iphone_info except: pass def change_status(self, table_name): try: sql = f"UPDATE trillion.{table_name} SET forinventory='0';" results = CommonDao.change_option(self, sql) return results except: pass def change_status_single(self, table_name, IEMI): try: sql = f"UPDATE trillion.{table_name} SET forinventory='1' WHERE IEMI='{IEMI}';" results = CommonDao.change_option(self, sql) return results except: pass def get_iphone_info_all_theory(self, table_name): try: sql = f"SELECT productlines, istorage, color FROM trillion.{table_name} WHERE bstorage='1';" iphone_info = CommonDao.search_option(self, sql) return iphone_info except: pass def get_iphone_info_all_actual(self, table_name): try: sql = f"SELECT productlines, istorage, color FROM trillion.{table_name} WHERE forinventory='1';" iphone_info = CommonDao.search_option(self, sql) return iphone_info except: pass
class TransferDao: def __init__(self): self.com_db = CommonDao() def get_product_lines(self): try: sql = "SELECT productlines FROM trillion.productlines;" product_lines = CommonDao.search_option(self, sql) if isinstance(product_lines, list): return product_lines else: product_lines = self.com_db.get_local_data("productlines") return product_lines except: product_lines = self.com_db.get_local_data("productlines") return product_lines def get_iphone_info(self, table_name, IEMI): try: sql = "SELECT istorage, color, productlines, grade FROM trillion.%s WHERE IEMI=%s;" % ( table_name, IEMI) iphone_info = CommonDao.search_option(self, sql) return iphone_info except: pass def get_iphone_type(self): try: sql = "SELECT iphonetype FROM trillion.iphonetype;" iphone_type = CommonDao.search_option(self, sql) if isinstance(iphone_type, list): return iphone_type else: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type except: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type def submit_transfer(self, values): try: sql = "UPDATE trillion.%s SET productlines='%s' WHERE IEMI='%s';" % values iphone_info = CommonDao.change_option(self, sql) return iphone_info except: pass def transfer_line_table(self, from_table, to_table, IEMI): # 修改转出表 result = self.change_line(from_table, IEMI, "0") # 修改转入表 result = self.change_line(to_table, IEMI, "1") return result def change_line(self, table_name, IEMI, bool): try: sql = f"INSERT INTO trillion.{table_name} (IEMI, changetime, bool) VALUES ({IEMI}, CURRENT_TIMESTAMP, {bool})" results = CommonDao.change_option(self, sql) return results except: pass def check_transfer_sum_count(self, table_name, start_time, end_time): try: sql = f"SELECT COUNT(IEMI) FROM trillion.{table_name} WHERE bool='0' AND changetime BETWEEN '{start_time}' AND '{end_time}';" result = CommonDao.search_option(self, sql) return result except: pass
class CheckCountDao: def __init__(self): self.com_db = CommonDao() def get_iphone_type(self): try: sql = "SELECT iphonetype FROM trillion.iphonetype;" iphone_type = CommonDao.search_option(self, sql) if isinstance(iphone_type, list): return iphone_type else: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type except: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type def get_iphone_storage(self): try: sql = "SELECT iphonestorage FROM trillion.iphonestorage;" iphone_storage = CommonDao.search_option(self, sql) if isinstance(iphone_storage, list): return iphone_storage else: iphone_storage = self.com_db.get_local_data("iphonestorage") return iphone_storage except: iphone_storage = self.com_db.get_local_data("iphonestorage") return iphone_storage def get_iphone_color(self): try: sql = "SELECT iphonecolor FROM trillion.iphonecolor;" iphone_color = CommonDao.search_option(self, sql) if isinstance(iphone_color, list): return iphone_color else: iphone_color = self.com_db.get_local_data("iphonecolor") return iphone_color except: iphone_color = self.com_db.get_local_data("iphonecolor") return iphone_color def get_all_count(self, table_name): try: sql = "SELECT COUNT(IEMI) FROM trillion.%s WHERE bstorage='1';" % table_name print(sql) all_count = CommonDao.search_option(self, sql) return all_count except: pass def get_all_count_condition(self, table_name, para, condition): try: if condition == "": sql = f"SELECT COUNT(IEMI) FROM trillion.{table_name} WHERE bstorage='1' AND grade is Null;" else: sql = "SELECT COUNT(IEMI) FROM trillion.%s WHERE bstorage='1' AND %s='%s';" % (table_name, para, condition) print(sql) all_count_condition = CommonDao.search_option(self, sql) return all_count_condition except: pass def get_storage_count(self, table_name, storage): try: sql = "SELECT COUNT(IEMI) FROM trillion.%s WHERE bstorage='1' AND istorage='%s';" % (table_name, storage) print(sql) storage_count = CommonDao.search_option(self, sql) return storage_count except: pass def get_storage_count_condition(self, table_name, storage, para, condition): try: if condition == "": sql = f"SELECT COUNT(IEMI) FROM trillion.{table_name} WHERE bstorage='1' AND istorage='{storage}' AND grade is Null;" else: sql = f"SELECT COUNT(IEMI) FROM trillion.{table_name} WHERE bstorage='1' AND istorage='{storage}' AND {para}='{condition}';" storage_count_condition = CommonDao.search_option(self, sql) return storage_count_condition except: pass def get_color_count(self, table_name, storage, color): try: sql = "SELECT COUNT(IEMI) FROM trillion.%s WHERE bstorage='1' AND istorage='%s' AND color='%s';" % (table_name, storage, color) color_count = CommonDao.search_option(self, sql) return color_count except: pass def get_color_count_condition(self, table_name, storage, color, para, condition): try: if condition == "": sql = f"SELECT COUNT(IEMI) FROM trillion.{table_name} WHERE bstorage='1' AND istorage='{storage}' AND color='{color}' AND grade is Null;" else: sql = f"SELECT COUNT(IEMI) FROM trillion.{table_name} WHERE bstorage='1' AND istorage='{storage}' AND color='{color}' AND {para}='{condition}';" print(sql) color_count_condition = CommonDao.search_option(self, sql) return color_count_condition except: pass
class ProductInDao: # 存入数据 def __init__(self): self.com_db = CommonDao() self.UI = Ui_MainWindow() def insert_data(self, values): try: sql = "INSERT INTO trillion.%s" \ "(IEMI, istorage, color, intime, company, productlines, bstorage, remarks, lotNo)" \ "VALUES" \ "('%s','%s','%s',CURRENT_TIMESTAMP,'%s','%s' ,'%s','%s', '%s');" % values results = CommonDao.change_option(self, sql) return results except: pass def get_iphone_type(self): try: sql = "SELECT iphonetype FROM trillion.iphonetype;" iphone_type = CommonDao.search_option(self, sql) if isinstance(iphone_type, list): return iphone_type else: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type except: iphone_type = self.com_db.get_local_data("iphonetype") return iphone_type def get_iphone_color(self): try: sql = "SELECT iphonecolor FROM trillion.iphonecolor;" iphone_color = CommonDao.search_option(self, sql) if isinstance(iphone_color, list): return iphone_color else: iphone_color = self.com_db.get_local_data("iphonecolor") return iphone_color except: iphone_color = self.com_db.get_local_data("iphonecolor") return iphone_color def get_iphone_storage(self): try: sql = "SELECT iphonestorage FROM trillion.iphonestorage;" iphone_storage = CommonDao.search_option(self, sql) if isinstance(iphone_storage, list): return iphone_storage else: iphone_storage = self.com_db.get_local_data("iphonestorage") return iphone_storage except: iphone_storage = self.com_db.get_local_data("iphonestorage") return iphone_storage def get_product_lines(self): try: sql = "SELECT productlines FROM trillion.productlines;" product_lines = CommonDao.search_option(self, sql) if isinstance(product_lines, list): return product_lines else: product_lines = self.com_db.get_local_data("productlines") return product_lines except Exception: product_lines = self.com_db.get_local_data("productlines") return product_lines def get_in_company(self): try: sql = "SELECT incompany FROM trillion.incompany;" in_company = CommonDao.search_option(self, sql) if isinstance(in_company, list): return in_company else: in_company = self.com_db.get_local_data("incompany") return in_company except: in_company = self.com_db.get_local_data("incompany") return in_company