from .flightDB import flightDB from unitls.LogerinTxt import app_logger import datetime def callon(fdb:flightDB,phonenum): try: now = datetime.datetime.now() now1=datetime.datetime.now()- datetime.timedelta(seconds=5) if phonenum !="" and phonenum !=None: calllist = fdb.sort_queryTable2("航班编号", "Calllist", "电话 ='%s' and 接通时间 =''"%phonenum, "拨号次数", "ASC", "创建时间", "ASC") if len(calllist) != 0: lasttime = fdb.sort_queryTable("接通时间", "Calllist", "接通时间 !='' and 接通时间 not like '%人工%'", "接通时间", "desc") #print("lasttime", lasttime[0][0]) if len(lasttime) == 0 or(len(lasttime) != 0 and now1 > datetime.datetime.strptime(lasttime[0][0][:19],"%Y-%m-%d %H:%M:%S")): newdic = {"接通时间": "'%s'" % now} fdb.upDateItem("Calllist", newdic, "航班编号='%s'" % calllist[0][0]) except Exception as e: app_logger.log_error(e)