def arrival_confirm(self, tmsBillCode=''): '''到达确认 司机发车确认''' try: self.logger.info('到达确认页面,选择到达确认的运单号:{0}'.format(tmsBillCode)) # 获取到付金额 destAmt = PageWaybillDetail(self.driver).get_amt(tmsBillCode)[0] # 打开到达确认页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[5]/a/span') # 输入查询内容查询运单 HeplerWaybill().fuzzy_query(self.driver, 'id->confirmNormalCondition', 'id->confirmNormalConditionButton', tmsBillCode) # 点击目的地到达按钮 self.driver.move_to_click('id->TMS-judgeSendCar-') self.driver.element_is_not_visible('class->loading-bar-background') # 确认到达 if destAmt == '': self.driver.move_to_click('id->TMS-submitConfirmWay-') else: # 修改到达确认金额 self.driver.clear_type('id->TMS-bill-actualPay', '0.02') self.driver.type('id->TMS-bill-memo', '修改到达金额') self.driver.move_to_click('id->TMS-submitConfirmWay-') self.driver.element_is_not_visible('class->loading-bar-background') except Exception as e: self.logger.error('到达确认 司机发车确认发生异常:{0}'.format(e)) return None
def payment_KEKING_TO_comment(self, tmsBillCode='', payMethod=''): '''发车支付页面 选择除余额支付以外支付方式支付''' try: # 打开发车支付页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/div/ul/li[2]/a/span') # 输入运单号查询运单 HeplerWaybill().fuzzy_query(self.driver, 'id->globalCondition', 'id->globalConditionButton', tmsBillCode) self.driver.element_is_not_visible('class->loading-bar-background') # 选择运单 self.driver.click('id->TMS-selectCheckbox-') # 点击支付按钮,打开支付弹窗 self.driver.click('id->TMS-toWayBillPay-') self.driver.element_is_not_visible('class->loading-bar-background') # 选择除余额支付以外支付方式 self.driver.click('{0}'.format(payMethod)) # 确认支付 self.driver.click('id->TMS-toPursePay-') self.driver.element_is_not_visible('class->loading-bar-background') except Exception as e: self.logger.error('发车支付页面 选择除余额支付以外支付方式支付:{0}'.format(e)) return None
def send_order(self, planNo=''): '''订单派车''' try: self.logger.info('订单派车的运单号:{0}'.format(planNo)) HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[3]/div/ul/li[1]/a/span') # 输入订单号查询订单 HeplerWaybill().input_query(self.driver, 'id->TMS-param-planNo', planNo, 'xpath->//*[@id="TMS-search-"]/span') # 点击派车按钮 self.driver.retry_find_click('id->TMS-listCargo-') self.driver.element_is_not_visible('class->loading-bar-background') self.driver.retry_find_click('id->TMS-dispatchedAndUpdateCargo-') self.driver.element_is_not_visible('class->loading-bar-background') # 打开运单管理模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/label/a') # 生成运单 waybillId, tmsBillCode = PageWaybillCreate( self.driver).jump_waybill_submit(driver='18056070532', index='1', totalAmt='100', income='100', preAmt='0.01', photoAirWay='', content='运单备注') return planNo, waybillId, tmsBillCode except Exception as e: self.logger.error('订单派车发生异常:{0}'.format(e)) return None, None, None
def singlePay_WALLET_TO_DRIVER(self, tmsBillCode=''): '''尾款支付页面 选择除余额支付方式支付''' try: # 打开尾款支付页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/div/ul/li[4]/a/span') # 输入运单号查询运单 HeplerWaybill().fuzzy_query(self.driver, 'id->globalCondition', 'id->globalConditionButton', tmsBillCode) # 选择运单 self.driver.click('id->TMS-selectCheckbox-') # 点击支付按钮,打开支付弹窗 self.driver.click('id->TMS-toWayBillPay-') self.driver.element_is_not_visible('class->loading-bar-background') # 选择余额支付 self.driver.click( 'xpath->//*[@id="wayBillPay"]/div/div/div[2]/div/form/div[2]/div[2]/table/tbody/tr[2]/td[4]/span/label' ) self.driver.element_is_not_visible('class->loading-bar-background') # 确认支付 self.driver.click('id->TMS-toPursePay-') self.driver.element_is_not_visible('class->loading-bar-background') # 输入支付密码并确认支付 self.config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() self.driver.type('id->sendcreate', self.config['payPassword']) self.driver.click('id->TMS-lianLianPay-') self.driver.element_is_not_visible('class->loading-bar-background') except Exception as e: self.logger.error('尾款支付页面 选择除余额支付方式支付:{0}'.format(e)) return None
def input_fee_car_waybill(self, project='', driver='', supplier='', index='0', totalAmt='', income='', preAmt='', oilAmt='', destAmt='', lastAmt='', photoAirWay='', content=''): '''选择外请车录单''' # 打开我要录单页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[2]/a/span') self.input_default_field(project, index, totalAmt, income, preAmt, oilAmt, destAmt, lastAmt, photoAirWay, content) #选择司机、车辆 HeplerWaybill().set_value_select_input(self.driver, "id->realName", driver) # 选择供应商 HeplerWaybill().set_value_select_input( self.driver, 'id->TMS-billModel-supplierName', supplier) # 输入有无回单 self.driver.select('id->TMS-billModel-hasReceipt', "index->{0}".format(index))
def input_own_car_waybill(self, project='', driver='', carNo='', index='0', totalAmt='', income='', preAmt='', oilAmt='', destAmt='', lastAmt='', photoAirWay='', content=''): '''选择自有车录单''' # 打开我要录单页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[2]/a/span') #选择公司车 self.driver.click("xpath->//*[@id='carOne']/i") #输入默认字段 self.input_default_field(project, index, totalAmt, income, preAmt, oilAmt, destAmt, lastAmt, photoAirWay, content) #选择司机 HeplerWaybill().set_value_select_input(self.driver, "id->realName", driver) #选择车辆 HeplerWaybill().set_value_select_input(self.driver, "id->innerCarNoId", carNo) # 输入有无回单 self.driver.select('id->TMS-billModel-hasReceipt', "index->{0}".format(index))
def input_default_field(self, project, index, totalAmt, income, preAmt, oilAmt, destAmt, lastAmt, photoAirWay, content): '''输入默认字段''' #输入用车日期 self.driver.retry_find_click("id->applyDate") self.driver.retry_find_click( "xpath->//*[@id='waybillAddForm']/div[1]/div[2]/div/div[2]/div/div/div/div/div/ul/li[2]/span/button[1]" ) #选择项目 HeplerWaybill().set_value_select_input(self.driver, "id->projectId", project) #输入始发地 HeplerWaybill().set_value_address(self.driver, "id->sendProvince", "xpath->//*[@id='_citys0']/a[1]", "xpath->//*[@id='_citys1']/a", "xpath->//*[@id='_citys2']/a[1]") #输入到达地 HeplerWaybill().set_value_address(self.driver, "id->arriveProvince", "xpath->//*[@id='_citys0']/a[2]", "xpath->//*[@id='_citys1']/a", "xpath->//*[@id='_citys2']/a[1]") #输入途径地1 self.driver.click('xpath->//*[@id="TMS-addStation-"]/span') HeplerWaybill().set_value_address(self.driver, "id->showStationA", "xpath->//*[@id='_citys0']/a[3]", "xpath->//*[@id='_citys1']/a[1]", "xpath->//*[@id='_citys2']/a[1]") #输入途径地2 self.driver.click('xpath->//*[@id="TMS-addStation-"]/span') HeplerWaybill().set_value_address(self.driver, "id->showStationB", "xpath->//*[@id='_citys0']/a[3]", "xpath->//*[@id='_citys1']/a[2]", "xpath->//*[@id='_citys2']/a[1]") # 输入总运费 self.driver.type('id->totalAmt', totalAmt) # 输入发车收入 self.driver.type('id->incomeId', income) # 输入预付 self.driver.type('id->TMS-billModel-preAmt', preAmt) # 输入油卡 self.driver.type('id->TMS-billModel-oilAmt', oilAmt) # 输入到付 self.driver.type('id->TMS-billModel-destAmt', destAmt) # 输入尾款''' self.driver.type('id->TMS-billModel-lastAmt', lastAmt) # 输入运输协议照片 self.driver.type('xpath->//*[@id="picOfTransport"]/div/div/div', photoAirWay) # 输入运单备注 self.driver.type('id->TMS-billModel-content', content)
def receipt_upload(self, tmsBillCode='', abnormal='0', remark='', actualAmt='', amtRemark='', receiptRemark=''): '''上传回单''' try: self.logger.info('回单录入页面,选择上传回单的运单号:{0}'.format(tmsBillCode)) # 判断运单是否已到达 trans_status = QueryWaybill().query_waybill_status(tmsBillCode) if trans_status != 'A': self.logger.info('选择上传的运单号:{0}运单状态不是已到达'.format(tmsBillCode)) # 打开回单录入页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[6]/a/span') # 输入查询内容查询运单 HeplerWaybill().fuzzy_query(self.driver, 'id->normalCondition', 'id->normalConditionButton', tmsBillCode) self.driver.element_is_not_visible('class->loading-bar-background') # 点击回单上传按钮 self.driver.move_to_click('id->TMS-showConfirm-') self.driver.element_is_not_visible('class->loading-bar-background') # 打开回单上传页面 # 选择没有异常 if abnormal == '0': Select(self.driver.get_element( 'id->TMS-bill-abnormal')).select_by_index(1) # 选择有异常 elif abnormal == '1': time.sleep(5) Select(self.driver.get_element( 'id->TMS-bill-abnormal')).select_by_index(0) self.driver.move_to_click('id->lostedforHW') self.driver.type('id->TMS-bill-damagedMemo', remark) else: self.logger.error( '请确认上传回单输入的参数abnormal是否正确:{0}'.format(abnormal)) self.driver.type('id->billShowActulAmt', actualAmt) self.driver.type('id->TMS-bill-memo', amtRemark) ###不上传回单照片 self.driver.type('id->TMS-bill-receptRemarks', receiptRemark) self.driver.move_to_click('id->upLoadImgSubMit') self.driver.element_is_not_visible('class->loading-bar-background') self.driver.move_to_click( 'xpath->//*[@id="myModal"]/div/div/div[3]/button') self.driver.element_is_not_visible('class->loading-bar-background') except Exception as e: self.logger.error('上传回单发生异常:{0}'.format(e)) return None
def get_arrived_waybill2(self, driver='', driverConfirm='0'): '''获取到达确认页面货主发车确认的运单号''' try: in_transit_waybillId, in_transit_tmsBillCode = ISHaveWaybill( ).is_have_in_transit_waybill(driver=driver, driverConfirm=driverConfirm)[:2] wait_departure_waybillId, wait_departure_tmsBillCode = ISHaveWaybill( ).is_have_wait_departure_waybill(driver=driver)[:2] # 打开运单管理模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/label/a') if in_transit_waybillId != None: waybillId, tmsBillCode = str(in_transit_waybillId[0]), str( in_transit_tmsBillCode[0]) return waybillId, tmsBillCode elif wait_departure_waybillId != None: waybillId, tmsBillCode = str(wait_departure_waybillId[0]), str( wait_departure_tmsBillCode[0]) # 货主发车确认 tmsBillCode = PageWaybillDeparture( self.driver).departure_confirm(tmsBillCode=tmsBillCode) return waybillId, tmsBillCode else: waybillId, tmsBillCode = PageWaybillCreate( self.driver).create_waybill_submit(driver=driver) # 货主发车确认 tmsBillCode = PageWaybillDeparture( self.driver).departure_confirm(tmsBillCode=tmsBillCode) return waybillId, tmsBillCode except Exception as e: self.logger.error('获取到达确认页面司机发车确认的运单号:{0}'.format(e)) return None
def get_payment_departure_waybill(self, driver='', driverConfirm='1'): '''获取发车支付页面的运单号''' try: payment_departure_waybillId, payment_departure_tmsBillCode = ISHaveWaybill( ).is_have_payment_departure_waybill( driver=driver, driverConfirm=driverConfirm)[:2] if payment_departure_waybillId != None: waybillId, tmsBillCode = str( payment_departure_waybillId[0]), str( payment_departure_tmsBillCode[0]) return waybillId, tmsBillCode else: waybillId, tmsBillCode = PageWaybillDeparture( self.driver).get_wait_departure_waybill(driver=driver) PageWaybillDeparture( self.driver).departure_confirm(tmsBillCode=tmsBillCode) if driverConfirm == '1': # 司机发车确认 DriverConfirmApi().driver_confirm_api(billId=waybillId, totalAmt='1000', preAmt='0.01', oilAmt='0.01', destAmt='0.01', lastAmt='0.01', receiverId='') return waybillId, tmsBillCode except Exception as e: self.logger.error('获取发车支付页面的运单号:{0}'.format(e)) return None, None finally: # 打开运费支付模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/label/a')
def get_send_order(self): '''获取已派车的订单号''' try: planNo_send = ISHaveOrder().is_have_order(orderStatus='2') planNo_sending = ISHaveOrder().is_have_order(orderStatus='1') planNo_noSend = ISHaveOrder().is_have_order(orderStatus='0') # 打开订单管理模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[3]/label/a') if planNo_send != None: return planNo_send elif planNo_sending != None: self.send_order(planNo=planNo_sending) return planNo_noSend elif planNo_noSend != None: self.send_order(planNo=planNo_noSend) return planNo_noSend else: planNo = PageOrderCreate(self.driver).create_order_submit() self.send_order(planNo=planNo) return planNo except Exception as e: self.logger.error('获取已派车的订单号发生异常:{0}'.format(e)) return None
def waybill_detail(self,tmsBillCode=''): '''运单详情''' try: self.logger.info("获取运单号:{0}的运单详情".format(tmsBillCode)) # 打开运单查询页面 HeplerWaybill().open_menu(self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[1]/a/span') # 输入查询内容查询运单 Select(self.driver.get_element('id->TMS-dateInterval')).select_by_index(1) HeplerWaybill().fuzzy_query(self.driver, 'id->normalCondition', 'id->TMS-normalSearch-', tmsBillCode) self.driver.element_is_not_visible('class->loading-bar-background') # 点击运单编号获取运单详情 self.driver.move_to_click('id->TMS-toDetail-') self.driver.element_is_not_visible('class->loading-bar-background') except Exception as e: self.logger.error('获取运单号{1}的运单详情发生异常:{0}'.format(e,tmsBillCode)) return None
def jump_waybill_submit(self, project='', driver='', supplier='', index='1', totalAmt='1000', income='2000', preAmt='0.01', oilAmt='0.01', destAmt='0.01', lastAmt='0.01', photoAirWay='', content=''): '''创建运单''' waybillId, tmsBillCode, driver_mobile = ISHaveWaybill( ).is_have_wait_departure_waybill(driver=driver) # 判断是否存在未发车的运单 if waybillId != None: self.logger.info("存在未发车确认的运单ID:{0}".format(waybillId)) DepartureConfirmApi().departure_confirm_api(str(waybillId[0])) self.input_default_field(project, index, totalAmt, income, preAmt, oilAmt, destAmt, lastAmt, photoAirWay, content) # 选择司机、车辆 HeplerWaybill().set_value_select_input(self.driver, "id->realName", driver) # 选择供应商 HeplerWaybill().set_value_select_input( self.driver, 'id->TMS-billModel-supplierName', supplier) # 输入有无回单 self.driver.select('id->TMS-billModel-hasReceipt', "index->{0}".format(index)) self.submit() # 获取创建运单运单号、运单ID self.DBUtil = DBUtil(host=self.config['db_host'], port=self.config['db_port'], user=self.config['db_user'], passwd=self.config['db_passwd'], dbname=self.config['db_dbname'], charset=self.config['db_charset']) sql1 = 'SELECT airWayBillNo ,tmsBillCode FROM YD_APP_TRANSPORTCASH WHERE mobile = \'{0}\' and billStatus = \'W\' ' \ 'and delStatus = \'0\' and partnerNo = \'{1}\''.format(driver_mobile, self.config['partnerNo']) waybillId, tmsBillCode = self.DBUtil.excute_select_one_record(sql1) return waybillId, tmsBillCode
def receipt_confirm(self, tmsBillCode='', waybillId='', receipt0='', actualAmt='', amtRemark='', receiptRemark=''): '''回单确认''' try: self.logger.info('回单录入页面,选择回单确认的运单号:{0}'.format(tmsBillCode)) # 判断运单是否已到达 trans_status = QueryWaybill().query_waybill_status(tmsBillCode) if trans_status == 'A': DriverUploadReceiptApi().driver_upload_receipt_api( waybillId=waybillId, receipt0=receipt0) else: self.logger.info('选择回单确认的运单号:{0}运单状态不是已到达'.format(tmsBillCode)) # 打开回单录入页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[6]/a/span') # 输入查询内容查询运单 HeplerWaybill().fuzzy_query(self.driver, 'id->normalCondition', 'id->normalConditionButton', tmsBillCode) self.driver.element_is_not_visible('class->loading-bar-background') # 点击回单确认按钮 self.driver.move_to_click('id->TMS-getReceiptMsg-') self.driver.element_is_not_visible('class->loading-bar-background') # 打开回单确认页面 self.driver.type('id->actualAmtConfirm', actualAmt) self.driver.type('id->TMS-recept-memo', amtRemark) ###不上传回单照片 self.driver.type('id->TMS-recept-receptRemarks', receiptRemark) self.driver.move_to_click('id->TMS-confirmReceip-') self.driver.element_is_not_visible('class->loading-bar-background') self.driver.move_to_click( 'xpath->//*[@id="myModal"]/div/div/div[3]/button') self.driver.element_is_not_visible('class->loading-bar-background') except Exception as e: self.logger.error('回单确认发生异常:{0}'.format(e)) return None
def cancel_waybill(self, tmsBillCode=''): '''取消运单''' try: self.logger.info('取消运单的运单运单号:{0}'.format(tmsBillCode)) # 跳转至发车确认页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[3]/a/span') # 输入查询内容查询运单 HeplerWaybill().fuzzy_query(self.driver, 'id->normalCondition', 'id->normalConditionButton', tmsBillCode) # 点击取消运单 self.driver.retry_find_click('id->TMS-confirmShow-') self.driver.element_is_visible('class->xcConfirm') self.driver.retry_find_click( 'xpath->//*[@class="xcConfirm"]/div[2]/div[3]/div/a[1]') return tmsBillCode except Exception as e: self.logger.error('取消运单发生异常:{0}'.format(e)) return None
def departure_confirm(self, tmsBillCode=''): '''发车确认''' try: self.logger.info('发车确认的运单号:{0}'.format(tmsBillCode)) # 打开发车确认页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[3]/a/span') # 输入查询内容查询运单 HeplerWaybill().fuzzy_query(self.driver, 'id->normalCondition', 'id->normalConditionButton', tmsBillCode) # 点击发车确认 self.driver.retry_find_click('id->TMS-sendCarConfirm-') self.driver.element_is_not_visible('class->loading-bar-background') self.driver.retry_find_click( 'xpath->//*[@id="sendCarTips"]/div/div/div[3]/button[1]') return tmsBillCode except Exception as e: self.logger.error('发车确认发生异常:{0}'.format(e)) return None
def cancel_order(self, planNo=''): '''取消订单''' try: self.logger.info('取消订单的运单号:{0}'.format(planNo)) # 打开订单查询页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[3]/div/ul/li[1]/a/span') # 输入订单号查询订单 HeplerWaybill().input_query(self.driver, 'id->TMS-param-planNo', planNo, 'xpath->//*[@id="TMS-search-"]/span') # 点击取消按钮 self.driver.retry_find_click('id->TMS-confirmShowByTitle-') self.driver.element_is_not_visible('class->loading-bar-background') self.driver.retry_find_click( 'xpath->//*[@class="xcConfirm"]/div[2]/div[3]/div/a[1]') return planNo except Exception as e: self.logger.error('取消订单发生异常:{0}'.format(e)) return None
def input_cargo(self, cargoName='', cargoWeight='', cargoVolume='', cargoCount='', unit='', cargoNo='', cargoWorth='', insuranceCosts=''): # 输入货物明细 HeplerWaybill().set_value_cargo(self.driver, cargoName, cargoWeight, cargoVolume, cargoCount, unit, cargoNo, cargoWorth, insuranceCosts)
def input_order(self, project='', orderRemark='', upOrderPlanNo=''): # 打开新建订单页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[3]/div/ul/li[2]/a/span') # 选择项目 self.driver.retry_find_click('id->projectId') self.driver.element_is_not_visible('class->loading-bar-background') self.driver.type('id->TMS-queryProjects-selectProject', project) self.driver.move_to_click('id->TMS-selectProject-') self.driver.type('id->planRemark', orderRemark) self.driver.type('id->TMS-billModel-upOrderPlanNo', upOrderPlanNo)
def payment_detail(self, tmsBillCode=''): '''支付详情''' try: # 打开支付查询页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/label', 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/div/ul/li[1]') # 输入查询内容查询运单 Select(self.driver.get_element( 'xpath->TMS-dateInterval')).select_by_index(0) HeplerWaybill().date_query(self.driver, index=all) HeplerWaybill().fuzzy_query(self.driver, 'id->normalCondition', 'xpath->TMS-payList-globalSearch-', tmsBillCode) # 点击详情按钮,打开支付详情页面 self.driver.retry_find_click( 'xpath->//*[@id="page-wrapper"]/div[2]/div[1]/div[2]/div[2]/table/tbody/tr[1]/td[34]/div/a' ) self.driver.element_is_not_visible('class->loading-bar-background') except Exception as e: self.logger.error('打开支付详情页面发生异常:{0}'.format(e)) return None
def get_noSend_order(self): '''获取未派车的订单号''' try: planNo = ISHaveOrder().is_have_order(orderStatus='0') HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[3]/label/a') if planNo != None: return planNo else: planNo = PageOrderCreate(self.driver).create_order_submit() return planNo except Exception as e: self.logger.error('获取未派车的订单号发生异常:{0}'.format(e)) return None
def copy_order(self, planNo='', project=''): '''复制订单''' try: self.logger.info('复制订单的运单号:{0}'.format(planNo)) # 打开订单查询页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[3]/div/ul/li[1]/a/span') # 输入订单号查询订单 HeplerWaybill().input_query(self.driver, 'id->TMS-param-planNo', planNo, 'xpath->//*[@id="TMS-search-"]/span') # 点击复制按钮 self.driver.move_to_click('id->TMS-copyPlanInfoToCreatePage-') self.driver.element_is_not_visible('class->loading-bar-background') # 重新选择项目 self.driver.move_to_click('id->projectId') self.driver.element_is_not_visible('class->loading-bar-background') self.driver.type('id->TMS-queryProjects-selectProject', project) self.driver.move_to_click('id->TMS-selectProject-') self.driver.element_is_not_visible('class->loading-bar-background') time.sleep(5) # 创建订单页面点击提交按钮 current_window = self.driver.driver.current_window_handle self.driver.move_to_click('id->TMS-saveOrderPlan-') self.driver.element_is_not_visible('class->loading-bar-background') all_windows = self.driver.driver.window_handles for window in all_windows: if window != current_window: self.driver.driver.switch_to.window(window) self.driver.retry_find_click( 'xpath->//*[@id="myModal"]/div/div/div[3]/button', secs=10) return planNo except Exception as e: self.logger.error('复制订单发生异常:{0}'.format(e)) return None
def get_waybill(self, driver=''): '''获取运单详情页面的运单号''' try: waybillId, tmsBillCode = ISHaveWaybill().is_have_waybill(driver=driver)[:2] # 打开运单管理模块 HeplerWaybill().open_menu(self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/label/a') if waybillId == None: waybillId, tmsBillCode = PageWaybillCreate(self.driver).create_waybill_submit(driver=driver) return waybillId, tmsBillCode else: return waybillId, tmsBillCode except Exception as e: self.logger.error('获取运单号的运单详情发生异常:{0}'.format(e)) return None
def get_waybill(self, driver=''): '''获取运单查询页面可删除的运单号''' try: waybillId, tmsBillCode = ISHaveWaybill().is_have_waybill( driver=driver)[:2] # 打开运单管理模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/label/a') if waybillId == None: waybillId, tmsBillCode = PageWaybillCreate( self.driver).create_waybill_submit(driver=driver) # 打开运单查询页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[1]/a/span' ) # 输入查询内容查询运单 Select(self.driver.get_element( 'id->TMS-dateInterval')).select_by_index(1) HeplerWaybill().fuzzy_query( self.driver, 'id->normalCondition', 'id->TMS-waybillIndex-normalSearch-', tmsBillCode) return waybillId, tmsBillCode else: # 打开运单查询页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[1]/a/span' ) # 输入查询内容查询运单 Select(self.driver.get_element( 'id->TMS-dateInterval')).select_by_index(1) HeplerWaybill().fuzzy_query(self.driver, 'id->normalCondition', 'TMS-normalSearch-', tmsBillCode) cName = self.driver.driver.find_element_by_id( 'TMS-showDialog-').get_attribute("class") if cName == 'btn btn-danger': return waybillId, tmsBillCode else: waybillId, tmsBillCode = PageWaybillCreate( self.driver).create_waybill_submit(driver=driver) # 打开运单查询页面 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/div/ul/li[1]/a/span' ) return waybillId, tmsBillCode except Exception as e: self.logger.error('获取运单查询页面可删除的运单号发生异常:{0}'.format(e)) return None
def get_arrived_waybill(self, driver='', driverConfirm='1'): '''获取到达确认页面司机发车确认的运单号''' try: in_transit_waybillId, in_transit_tmsBillCode = ISHaveWaybill( ).is_have_in_transit_waybill(driver=driver, driverConfirm=driverConfirm)[:2] wait_departure_waybillId, wait_departure_tmsBillCode = ISHaveWaybill( ).is_have_wait_departure_waybill(driver=driver)[:2] # 打开运单管理模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/label/a') if in_transit_waybillId != None: waybillId, tmsBillCode = str(in_transit_waybillId[0]), str( in_transit_tmsBillCode[0]) return waybillId, tmsBillCode elif wait_departure_waybillId != None: waybillId, tmsBillCode = str(wait_departure_waybillId[0]), str( wait_departure_tmsBillCode[0]) # 司机发车确认 DriverConfirmApi().driver_confirm_api(billId=waybillId, totalAmt='1000', preAmt='0.01', oilAmt='0.01', destAmt='0.01', lastAmt='0.01', receiverId='') return waybillId, tmsBillCode else: waybillId, tmsBillCode = PageWaybillCreate( self.driver).create_waybill_submit(driver=driver) # 司机发车确认 DriverConfirmApi().driver_confirm_api(billId=waybillId, totalAmt='1000', preAmt='0.01', oilAmt='0.01', destAmt='0.01', lastAmt='0.01', receiverId='') return waybillId, tmsBillCode except Exception as e: self.logger.error('获取到达确认页面司机发车确认的运单号:{0}'.format(e)) return None
def open_order_manage(self): # 打开订单管理模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[3]/label/a')
def get_payment_lastAmt_waybill(self, driver='', driverConfirm='1'): '''获取尾款支付页面的运单号''' try: self.login() payment_lastAmt_waybillId, payment_lastAmt_tmsBillCode = ISHaveWaybill( ).is_have_payment_lastAmt_waybill(driver=driver, driverConfirm=driverConfirm)[:2] payment_arrival_waybillId, payment_arrival_tmsBillCode = ISHaveWaybill( ).is_have_payment_arrival_waybill(driver=driver, driverConfirm=driverConfirm)[:2] payment_departure_waybillId, payment_departure_tmsBillCode = ISHaveWaybill( ).is_have_payment_departure_waybill( driver=driver, driverConfirm=driverConfirm)[:2] completed_waybillId, completed_tmsBillCode = ISHaveWaybill( ).is_have_completed_waybill(driver=driver)[:2] arrived_waybillId, arrived_tmsBillCode = ISHaveWaybill( ).is_have_arrived_waybill(driver=driver)[:2] if payment_lastAmt_waybillId != None: waybillId, tmsBillCode = str( payment_lastAmt_waybillId[0]), str( payment_lastAmt_tmsBillCode[0]) # 打开运费支付模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/label/a') self.logger.info('待尾款支付的运单编号:{0}'.format(tmsBillCode)) return waybillId, tmsBillCode elif payment_arrival_waybillId != None and completed_waybillId != None and payment_arrival_waybillId == completed_waybillId: waybillId, tmsBillCode = str( payment_arrival_waybillId[0]), str( payment_arrival_tmsBillCode[0]) # 打开运费支付模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/label/a') PagePaymentArrival( self.driver).singlePay_OFFLINE(tmsBillCode=tmsBillCode) self.driver.click('id->TMS-toList-') self.driver.element_is_not_visible( 'class->loading-bar-background') self.logger.info( '待到达支付且运单状态为已完成的运单编号:{0}, 到达支付'.format(tmsBillCode)) return waybillId, tmsBillCode elif payment_departure_waybillId != None and completed_waybillId != None and payment_departure_waybillId == completed_waybillId: waybillId, tmsBillCode = str( payment_departure_waybillId[0]), str( payment_departure_tmsBillCode[0]) # 打开运费支付模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/label/a') PagePaymentDeparture( self.driver).singlePay_OFFLINE(tmsBillCode=tmsBillCode) self.driver.click('id->TMS-toList-') self.driver.element_is_not_visible( 'class->loading-bar-background') PagePaymentArrival( self.driver).singlePay_OFFLINE(tmsBillCode=tmsBillCode) self.driver.click('id->TMS-toList-') self.driver.element_is_not_visible( 'class->loading-bar-background') self.logger.info( '待发车支付且运单状态为已完成的运单编号:{0}, 发车支付&到达支付'.format(tmsBillCode)) return waybillId, tmsBillCode elif payment_departure_waybillId != None and arrived_waybillId != None and payment_departure_waybillId == arrived_waybillId: waybillId, tmsBillCode = str( payment_departure_waybillId[0]), str( payment_departure_tmsBillCode[0]) # 打开运单管理模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/label/a') PageWaybillReceipt( self.driver).receipt_upload(tmsBillCode=tmsBillCode) # 打开运费支付模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/label/a') PagePaymentDeparture( self.driver).singlePay_OFFLINE(tmsBillCode=tmsBillCode) self.driver.click('id->TMS-toList-') self.driver.element_is_not_visible( 'class->loading-bar-background') PagePaymentArrival( self.driver).singlePay_OFFLINE(tmsBillCode=tmsBillCode) self.driver.click('id->TMS-toList-') self.driver.element_is_not_visible( 'class->loading-bar-background') self.logger.info( '待发车支付且运单状态为已已到达的运单编号:{0}, 上传回单&发车支付&到达支付'.format( tmsBillCode)) return waybillId, tmsBillCode else: waybillId, tmsBillCode = PageWaybillDeparture( self.driver).get_wait_departure_waybill(driver=driver) if driverConfirm == '1': # 司机发车确认 DriverConfirmApi().driver_confirm_api(billId=waybillId, totalAmt='1000', preAmt='0.01', oilAmt='0.01', destAmt='0.01', lastAmt='0.01', receiverId='') PageWaybillArrival( self.driver).arrival_confirm(tmsBillCode=tmsBillCode) elif driverConfirm == '0': PageWaybillDeparture( self.driver).departure_confirm(tmsBillCode=tmsBillCode) PageWaybillArrival( self.driver).arrival_confirm2(tmsBillCode=tmsBillCode) else: self.logger.error( '是否司机发车确认输入参数错误:{0}'.format(driverConfirm)) PageWaybillReceipt( self.driver).receipt_upload(tmsBillCode=tmsBillCode) # 打开运费支付模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[5]/label/a') PagePaymentDeparture( self.driver).singlePay_OFFLINE(tmsBillCode=tmsBillCode) self.driver.click('id->TMS-toList-') self.driver.element_is_not_visible( 'class->loading-bar-background') PagePaymentArrival( self.driver).singlePay_OFFLINE(tmsBillCode=tmsBillCode) self.driver.click('id->TMS-toList-') self.driver.element_is_not_visible( 'class->loading-bar-background') self.logger.info( '获取待发车的运单编号:{0}, 发车确认&到达确认&回单上传&发车支付&到达支付'.format( tmsBillCode)) return waybillId, tmsBillCode except Exception as e: self.logger.error('获取尾款支付页面的运单号:{0}'.format(e)) return None, None
def get_arrived_waybill(self, driver='', driverConfirm=''): '''获取回单录入页面的运单号''' try: in_transit_waybillId, in_transit_tmsBillCode = ISHaveWaybill( ).is_have_in_transit_waybill(driver=driver, driverConfirm=driverConfirm)[:2] wait_departure_waybillId, wait_departure_tmsBillCode = ISHaveWaybill( ).is_have_wait_departure_waybill(driver=driver)[:2] # 打开运单管理模块 HeplerWaybill().open_menu( self.driver, 'xpath->//*[@id="menu"]/div/nav/ul/li[4]/label/a') if in_transit_waybillId != None: waybillId, tmsBillCode = str(in_transit_waybillId[0]), str( in_transit_tmsBillCode[0]) if driverConfirm == '1': PageWaybillArrival( self.driver).arrival_confirm(tmsBillCode=tmsBillCode) self.driver.move_to_click( 'xpath->//*[@id="myModal"]/div/div/div[3]/button') self.driver.element_is_not_visible( 'class->loading-bar-background') self.logger.info('司机发车确认的运单 到达确认:{0}'.format(tmsBillCode)) elif driverConfirm == '0': PageWaybillArrival( self.driver).arrival_confirm2(tmsBillCode=tmsBillCode) self.driver.move_to_click( 'xpath->//*[@id="myModal"]/div/div/div[3]/button') self.driver.element_is_not_visible( 'class->loading-bar-background') self.logger.info('货主发车确认的运单 到达确认:{0}'.format(tmsBillCode)) else: self.logger.error('请确认运单是否发车确认:{0}'.format(tmsBillCode)) return waybillId, tmsBillCode elif wait_departure_waybillId != None: waybillId, tmsBillCode = str(wait_departure_waybillId[0]), str( wait_departure_tmsBillCode[0]) PageWaybillDeparture( self.driver).departure_confirm(tmsBillCode=tmsBillCode) PageWaybillArrival( self.driver).arrival_confirm2(tmsBillCode=tmsBillCode) self.driver.move_to_click( 'xpath->//*[@id="myModal"]/div/div/div[3]/button') self.driver.element_is_not_visible( 'class->loading-bar-background') self.logger.info('待发车的运单 货主发车确认 到达确认:{0}'.format(tmsBillCode)) return waybillId, tmsBillCode else: waybillId, tmsBillCode = PageWaybillCreate( self.driver).create_waybill_submit(driver=driver) PageWaybillDeparture( self.driver).departure_confirm(tmsBillCode=tmsBillCode) PageWaybillArrival( self.driver).arrival_confirm2(tmsBillCode=tmsBillCode) self.driver.move_to_click( 'xpath->//*[@id="myModal"]/div/div/div[3]/button') self.driver.element_is_not_visible( 'class->loading-bar-background') self.logger.info('新建运单 货主发车确认 到达确认:{0}'.format(tmsBillCode)) return waybillId, tmsBillCode except Exception as e: self.logger.error('获取回单录入页面的运单号:{0}'.format(e)) return None, None