def run(self): while True: print(f"\n{'#':=<9}#\n# 预约前 #\n{'#':=<9}#") self.usPipe = UsPipeline() # print('数据库连接完毕...') data = self.usPipe.selAppointment() if not data: if hasattr(self, "usPay"): del self.usPay print('没有数据, 等待中...', strftime('%m/%d %H:%M:%S')) sleep(5) os.system("cls") continue # ======= # 数据处理 # ======= # 判断是否需要申请 print('有数据进行提交\n') # 获取需要申请的人员信息 self.usPay = AutoPay( data=self.usPipe.order_data, usPipe=self.usPipe, # noWin=True ) email_info = self.usPipe.get_group_email( self.usPipe.order_data[0]["mpid"]) if not email_info and email_info["status"] != 1: if not self.usPay.res["register_is"]: self.register() self.usPay.payInfo() else: self.usPay.groupAppointment()
class RunAppointment: """ 预约 """ def __init__(self): self.data = None self.id = '' def run(self): while True: if hasattr(self, "usPay"): del self.usPay print(f"\n{'#':=<7}#\n# 预约 #\n{'#':=<7}#") try: self.usPipe = UsPipeline() except: print('数据库连接超时...重连...') continue # print('数据库连接完毕...') data = self.usPipe.selDBOrder() if not data: print('没有数据, 等待中...', strftime('%m/%d %H:%M:%S')) sleep(5) os.system("cls") continue # ======= # 数据处理 # ======= # 判断是否需要申请 print('有数据进行提交\n') # 获取需要申请的人员信息 self.usPay = AutoPay(data=self.usPipe.order_data, usPipe=self.usPipe, noWin=False) email_info = self.usPipe.get_group_email( self.usPipe.order_data[0]["mpid"]) if email_info["status"] != 1: if self.id != self.usPay.res["id"]: self.id = self.usPay.res["id"] self.usPay.login() if self.usPay.res["python_status"] == 1 or self.usPay.res[ "interview_status"] == 4: self.usPay.getDate() if self.usPay.res["interview_status"] == 4: self.usPay.appointment() elif self.usPay.res["interview_status"] == 9: self.usPay.cancel() else: self.usPay.group_pay_over()
def get_datas(): global app_datas, ids usPipe = UsPipeline() while 1: if lock.acquire(): sql = "SELECT id FROM dc_business_america_order WHERE interview_status=%s" all_id = usPipe.getAll(sql, 7) for i in all_id: if app_datas.full(): break if i["id"] in ids: continue print("队列填充中: + ", i["id"]) ids.add(i["id"]) app_datas.put(i["id"], timeout=1) # sleep(0.1) lock.release()
def run(self): while True: os.system("cls") print(f"\n{'#':=<7}#\n# 预约 #\n{'#':=<7}#") try: self.usPipe = UsPipeline() except Exception: print('数据库连接超时...重连...') continue # print('数据库连接完毕...') data = self.usPipe.selDBOrder() if data: # ======= # 数据处理 # ======= # 判断是否需要申请 print('有数据进行提交\n') # 获取需要申请的人员信息 self.usPay = AutoPay(data=self.usPipe.order_data, usPipe=self.usPipe, noWin=False) email_info = self.usPipe.get_group_email( self.usPipe.order_data[0]["mpid"]) if email_info["status"] != 1: if self.id != self.usPay.res["id"]: self.id = self.usPay.res["id"] self.usPay.login() if self.usPay.res["python_status"] == 1 or self.usPay.res[ "interview_status"] == 4: self.usPay.getDate() if self.usPay.res["interview_status"] == 4: self.usPay.appointment() elif self.usPay.res["interview_status"] == 9: self.usPay.cancel() else: self.usPay.group_pay_over() else: print('没有数据, 等待中...', strftime('%m/%d %H:%M:%S')) if hasattr(self, 'usPay') and hasattr(self.usPay, 'driver'): self.usPay.driver.quit() del self.usPay sleep(5)
def appointment(name): global app_datas, ids while 1: usPipe = UsPipeline() if app_datas.qsize(): oid = app_datas.get(timeout=1) sql = "SELECT * FROM dc_business_america_order WHERE id=%s AND interview_status=7" order = usPipe.getOne(sql, oid) if not order: continue print(name, "有数据提交 order表 id:", oid) sql = "SELECT * FROM dc_business_america_public_eng WHERE order_id=%s" publics = usPipe.getAll(sql, order["id"]) if not publics: continue infos = [] works = [] for i in publics: sql = "SELECT * FROM dc_business_america_info_eng WHERE aid=%s" infos.append(usPipe.getOne(sql, i["aid"])) sql = "SELECT * FROM dc_business_america_work_eng WHERE aid=%s" works.append(usPipe.getOne(sql, i["aid"])) autoPay = AutoPay(data=[order, publics, infos, works], usPipe=usPipe, noWin=True) if autoPay.group_pay_over(1): sleep(1) print(f"{name} - remove {oid}") ids.remove(oid) else: print(f"\n{name} No Datas ...", strftime("%m-%d %H:%M:%S")) sleep(30)
def run(self): # ======== # 开始执行 # ======== while True: print(f"\n{'#':=<8}#\n# DS160 #\n{'#':=<8}#") print(strftime("%Y-%m-%d %H-%M-%S")) self.auto = UsPipeline() # print('数据库连接完毕...') # 获取数据库信息 data = self.auto.selDBInfo # 判断是否需要申请 if data: # ======= # 数据处理 # ======= print('有数据进行提交\n') self.au = AllPage(data=self.auto.data, noWin=False, usPipe=self.auto) try: self.control[self.au.resPublic["visa_status"]]() except Exception as e: print(e) if hasattr(self.au, 'driver'): self.au.driver.quit() self.au.getDriver() else: self.auto = None self.au = None print('没有数据, 等待中...', strftime('%m/%d %H:%M:%S')) sleep(5) # os.system("cls") try: self.au.driver.quit() except Exception: pass