コード例 #1
0
    def setUp(self):
        self.logger = Log()
        self.logger.info(
            '######################## TestProfitReportSelect START ########################'
        )
        carType = str(random.randint(1, 2))
        self.applyDate = time.strftime('%Y-%m-%d')
        photoAirWay = FileUtil.getProjectObsPath() + '/image/photoAirWay.jpg'
        receipt_0 = FileUtil.getProjectObsPath(
        ) + os.path.sep + 'image' + os.path.sep + 'logo.png'

        wayBillId = CreateWayBill().create_waybill(
            carType, self.applyDate, photoAirWay, '北京', '北京', '', '天津', '天津',
            '', '1000', '10', '0.01', '0.02', '0.03', '0.04', '1', '备注我要录单测试',
            'TMS', '零担', '10', '100', '1000', '10000', '100000', '20', '30',
            '40', '50', 'DD001', 'YK001', 'LSVAM4187C2184847', '6222810001000',
            '中国银行', '张三')[0]
        WayBillDepartureConfirm().waybill_departure_confirm(wayBillId)
        waybill_transport_detail = WayBillDetailGet().waybill_detail_get(
            wayBillId).json()['content']
        self.wayBillNo = waybill_transport_detail['transportCash'][
            'tmsBillCode']
        WayBillArrivalConfirm().waybill_arrival_confirm(
            wayBillId, waybill_transport_detail['transportCash']['destAmt'],
            waybill_transport_detail['transportCash']['destAmtMemo'])
        WayBillReceiptUpload().waybill_receipt_upload(wayBillId, 'Y', 'Y', 'N',
                                                      '回单上传测试', 'C', receipt_0)
        waybill_arrived_detail = WayBillDetailGet().waybill_detail_get(
            wayBillId).json()['content']
        WayBillReceiptConfirm().waybill_receipt_confirm(
            wayBillId, waybill_arrived_detail['transportCash']['retAmt'],
            '金额变动', '有异常', receipt_0)
コード例 #2
0
 def test_waybill_receipt_get_success(self):
     '''获取回单详情'''
     WayBillDepartureConfirm().waybill_departure_confirm(self.wayBillId)
     waybill_transport_detail = WayBillDetailGet().waybill_detail_get(
         self.wayBillId).json()['content']
     WayBillArrivalConfirm().waybill_arrival_confirm(
         self.wayBillId,
         waybill_transport_detail['transportCash']['destAmt'],
         waybill_transport_detail['transportCash']['destAmtMemo'])
     WayBillReceiptUpload().waybill_receipt_upload(self.wayBillId, 'Y', 'Y',
                                                   'N', '回单上传测试', 'C',
                                                   self.receipt_0)
     response = WayBillReceiptGet().waybill_receipt_get(self.wayBillId)
     self.logger.info('获取回单详情回状态码:{0}'.format(response))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.json()['code'], 0)
     self.logger.info('获取回单详情返回结果:{0}'.format(response.json()))
     waybill_arrived_detail = WayBillDetailGet().waybill_detail_get(
         self.wayBillId).json()['content']
     self.logger.info('获取回单详情的运单号是:{0}'.format(
         waybill_arrived_detail['transportCashDetail']['tmsBillCode']))
     self.assertEqual(waybill_arrived_detail['transportCash']['billStatus'],
                      'H')
     self.assertEqual(
         waybill_arrived_detail['transportCash']['transStatus'], 'A')
コード例 #3
0
 def test_waybill_receipt_confirm_success(self):
     '''货主回单上传、回单确认'''
     WayBillDepartureConfirm().waybill_departure_confirm(self.wayBillId)
     waybill_transport_detail = WayBillDetailGet().waybill_detail_get(self.wayBillId).json()['content']
     WayBillArrivalConfirm().waybill_arrival_confirm(self.wayBillId,waybill_transport_detail['transportCash']['destAmt'],
                                                     waybill_transport_detail['transportCash']['destAmtMemo'])
     WayBillReceiptUpload().waybill_receipt_upload(self.wayBillId,'Y','Y','N','回单上传测试','C',self.receipt_0)
     waybill_arrived_detail = WayBillDetailGet().waybill_detail_get(self.wayBillId).json()['content']
     response = WayBillReceiptConfirm().waybill_receipt_confirm(self.wayBillId,
                waybill_arrived_detail['transportCash']['retAmt'],'金额变动','有异常')
     self.logger.info('回单确认返回状态码:{0}'.format(response))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.json()['code'], 0)
     waybill_completed_detail = WayBillDetailGet().waybill_detail_get(self.wayBillId).json()['content']
     self.logger.info('回单确认的运单号是:{0}'.format(waybill_completed_detail['transportCashDetail']['tmsBillCode']))
     self.assertEqual(waybill_completed_detail['transportCash']['billStatus'], 'S')
     self.assertEqual(waybill_completed_detail['transportCash']['transStatus'],'C')
コード例 #4
0
    def test_waybill_arrival_confirm_success(self):
        '''到达确认'''
        WayBillDepartureConfirm().waybill_departure_confirm(self.wayBillId)
        waybill_transport_detail = WayBillDetailGet().waybill_detail_get(
            self.wayBillId).json()['content']
        response = WayBillArrivalConfirm().waybill_arrival_confirm(
            self.wayBillId,
            waybill_transport_detail['transportCash']['destAmt'],
            waybill_transport_detail['transportCash']['destAmtMemo'])
        self.logger.info('到达确认返回状态码:{0}'.format(response))

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.json()['code'], 0)
        waybill_arrived_detail = WayBillDetailGet().waybill_detail_get(
            self.wayBillId).json()['content']
        self.logger.info('到达确认的运单号是:{0}'.format(
            waybill_arrived_detail['transportCashDetail']['tmsBillCode']))
        self.assertEqual(waybill_arrived_detail['transportCash']['billStatus'],
                         'D')
        self.assertEqual(
            waybill_arrived_detail['transportCash']['transStatus'], 'A')
コード例 #5
0
    def create_waybill_register(self,
                                handlingFee='',
                                deliveryFee='',
                                oilCardDeposit='',
                                otherFee=''):
        """ 使用已认证司机新建运单 """
        try:

            applyDate = time.strftime('%Y-%m-%d')
            photoAirWay = FileUtil.getProjectObsPath(
            ) + '/image/photoAirWay.jpg'
            upWayBillId = time.strftime('%Y%m%d%H%M%S',
                                        time.localtime(time.time()))[2:] + str(
                                            random.randint(100, 999))
            project = CreateWayBill().project_choice()
            supplier = CreateWayBill().supplier_choice()
            # 随机选择一个已认证的外请车
            mobile_certificate = self.config['mobile_certificate']
            mobile_certificate = random.sample(mobile_certificate, 1)[0]
            # 获取认证司机的信息
            driver = DriverMobileSelect().driver_mobile_select(
                mobile_certificate).json()['content'][0]
            self.logger.info('获取已认证司机信息:{0}'.format(driver))
            # 判断司机是否有未发车的运单
            sql = 'SELECT id FROM YD_APP_TRANSPORTCASH WHERE mobile = \'{0}\' and billStatus = \'W\' and ' \
                  'delStatus = \'0\' and partnerNo = \'{1}\''.format(driver['mobile'], self.config['partnerNo'])
            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'])
            waybillId_ = self.DBUtil.excute_select_one_record(sql)
            self.logger.info("已认证外请车存在未发车确认的运单ID:{0}".format(waybillId_))
            if waybillId_ == None:
                pass
            else:
                WayBillDepartureConfirm().waybill_departure_confirm(
                    waybillId_[0])
            # 创建运单
            response = WayBillCreate().waybill_create(
                '2',
                applyDate,
                project['projectName'],
                project['projectId'],
                supplier['name'],
                supplier['supplierId'],
                driver['name'],
                driver['idNo'],
                driver['mobile'],
                driver['carNo'],
                driver['carLength'],
                driver['carModel'],
                photoAirWay,
                driver['loginId'],
                sendProvince='北京',
                sendCity='北京',
                sendDistrict='',
                arriveProvince='天津',
                arriveCity='天津',
                arriveDistrict='',
                income='1000',
                totalAmt='0.05',
                preAmt='0.01',
                oilAmt='0.01',
                destAmt='0.01',
                lastAmt='0.01',
                hasReceipt='1',
                content='auto备注测试',
                source='TMS',
                cargoName='零担',
                cargoWeight='10',
                cargoVolume='100',
                cargoNumberOfCases='1000',
                cargoWorth='10000',
                insuranceCosts='10000',
                handlingFee=handlingFee,
                deliveryFee=deliveryFee,
                oilCardDeposit=oilCardDeposit,
                otherFee=otherFee,
                upWayBillId=upWayBillId,
                oilCardNo='YK001',
                vehicleIdNo='LSVAM4187C2184847',
                driverCardNo='6222810001000',
                depositBank='中国银行合肥分行',
                accountName='auto张三')
            wayBillId = response.json()['content']
            self.logger.info('使用已认证司机创建的运单ID是:{0}'.format(wayBillId))
            #司机发车确认
            confirmMsg = WayBillDriverConfirm().waybill_driver_confirm(
                wayBillId,
                totalAmt='0.05',
                preAmt='0.01',
                oilAmt='0.01',
                destAmt='0.01',
                lastAmt='0.01')
            self.logger.info('运单ID{0},司机确认发车返回结果:{1}'.format(
                wayBillId, confirmMsg.json()))
            return wayBillId
        except Exception as e:
            self.logger.info('新建已认证外请车运单公共模块发生异常:{0}'.format(e))
            return None
コード例 #6
0
    def create_waybill(self, carType, applyDate, photoAirWay, sendProvince,
                       sendCity, sendDistrict, arriveProvince, arriveCity,
                       arriveDistrict, income, totalAmt, preAmt, oilAmt,
                       destAmt, lastAmt, hasReceipt, content, source,
                       cargoName, cargoWeight, cargoVolume, cargoNumberOfCases,
                       cargoWorth, insuranceCosts, handlingFee, deliveryFee,
                       oilCardDeposit, otherFee, upWayBillId, oilCardNo,
                       vehicleIdNo, driverCardNo, depositBank, accountName):
        try:
            project = CreateWayBill().project_choice()
            supplier = CreateWayBill().supplier_choice()
            if carType == '1':
                car = CreateWayBill.car_choice()
                driver = CreateWayBill.driver_choice()
                response = WayBillCreate().waybill_create(
                    carType, applyDate, project['projectName'],
                    project['projectId'], supplier['name'],
                    supplier['supplierId'], driver['name'], driver['idNo'],
                    driver['mobile'], car['carNo'], car['carLength'],
                    car['carModel'], photoAirWay, '', sendProvince, sendCity,
                    sendDistrict, arriveProvince, arriveCity, arriveDistrict,
                    income, totalAmt, preAmt, oilAmt, destAmt, lastAmt,
                    hasReceipt, content, source, cargoName, cargoWeight,
                    cargoVolume, cargoNumberOfCases, cargoWorth,
                    insuranceCosts, handlingFee, deliveryFee, oilCardDeposit,
                    otherFee, upWayBillId, oilCardNo, '', '', '', '')
                self.logger.info("公司车创建运单公共模块response:{0}".format(
                    response.json()))
                if response.json()['code'] == 0:
                    return response.json()['content'],driver['mobile'],driver['name'],driver['idNo'],car['carNo'],\
                           car['carLength'],car['carModel'],project['projectName'],project['projectId'],\
                           supplier['name'], supplier['supplierId']

                elif response.json()['code'] == 9040104 and response.json()['msg'] == \
                        '此手机号已有未确认的订单,不可重复提交,请发车确认后再录单':
                    sql = 'SELECT id FROM YD_APP_TRANSPORTCASH WHERE mobile = \'{0}\' and billStatus = \'W\' and  ' \
                          'delStatus = \'0\' and partnerNo = \'{1}\''.format(driver['mobile'], self.config['partnerNo'])
                    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'])
                    waybillId_ = self.DBUtil.excute_select_one_record(sql)
                    self.logger.info("公司车存在未发车确认的运单ID:{0}".format(
                        waybillId_[0]))
                    response_departure_confirm = WayBillDepartureConfirm(
                    ).waybill_departure_confirm(waybillId_[0])
                    self.logger.info("发车确认返回结果:{0}".format(
                        response_departure_confirm.json()))
                    response_ = WayBillCreate().waybill_create(
                        carType, applyDate, project['projectName'],
                        project['projectId'], supplier['name'],
                        supplier['supplierId'], driver['name'], driver['idNo'],
                        driver['mobile'], car['carNo'], car['carLength'],
                        car['carModel'], photoAirWay, '', sendProvince,
                        sendCity, sendDistrict, arriveProvince, arriveCity,
                        arriveDistrict, income, totalAmt, preAmt, oilAmt,
                        destAmt, lastAmt, hasReceipt, content, source,
                        cargoName, cargoWeight, cargoVolume,
                        cargoNumberOfCases, cargoWorth, insuranceCosts,
                        handlingFee, deliveryFee, oilCardDeposit, otherFee,
                        upWayBillId, oilCardNo, '', '', '', '')
                    self.logger.info("公司车发车确认后,再次录单返回结果:{0}".format(
                        response_.json()))
                    waybillId = response_.json()['content']
                    return waybillId,driver['mobile'],driver['name'],driver['idNo'],car['carNo'],\
                           car['carLength'],car['carModel'],project['projectName'],project['projectId'],\
                           supplier['name'],supplier['supplierId']

                else:
                    self.logger.info("创建公司车运单公共模块失败!")
                    return None, None, None, None, None, None, None, None, None, None, None

            elif carType == '2':
                outCar = CreateWayBill().outCar_choice()
                driver_info = DriverBankVINGet().driver_bank_VIN_get(
                    outCar['mobile'], ).json()['content']
                response = WayBillCreate().waybill_create(
                    carType, applyDate, project['projectName'],
                    project['projectId'], supplier['name'],
                    supplier['supplierId'], outCar['name'], outCar['idNo'],
                    outCar['mobile'], outCar['carNo'], outCar['carLength'],
                    outCar['carModel'], photoAirWay, outCar['loginId'],
                    sendProvince, sendCity, sendDistrict, arriveProvince,
                    arriveCity, arriveDistrict, income, totalAmt, preAmt,
                    oilAmt, destAmt, lastAmt, hasReceipt, content, source,
                    cargoName, cargoWeight, cargoVolume, cargoNumberOfCases,
                    cargoWorth, insuranceCosts, handlingFee, deliveryFee,
                    oilCardDeposit, otherFee, upWayBillId, oilCardNo,
                    driver_info['vehicleIdNo'], driver_info['cardNo'],
                    driver_info['driverCardBank'], driver_info['accountName'])
                self.logger.info("外请车创建运单公共模块response:{0}".format(
                    response.json()))
                if response.json()['code'] == 0:
                    return response.json()['content'],outCar['mobile'],outCar['name'],outCar['idNo'],outCar['carNo'],\
                           outCar['carLength'],outCar['carModel'],project['projectName'], project['projectId'],\
                           supplier['name'], supplier['supplierId']

                elif response.json()['code'] == 9040104 and response.json()['msg'] ==\
                          '此手机号已有未确认的订单,不可重复提交,请发车确认后再录单':
                    sql = 'SELECT id FROM YD_APP_TRANSPORTCASH WHERE mobile = \'{0}\' and billStatus = \'W\' and ' \
                          'delStatus = \'0\' and partnerNo = \'{1}\''.format(outCar['mobile'], self.config['partnerNo'])
                    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'])
                    waybillId_ = self.DBUtil.excute_select_one_record(sql)
                    self.logger.info("公司车存在未发车确认的运单ID:{0}".format(
                        waybillId_[0]))
                    response_departure_confirm = WayBillDepartureConfirm(
                    ).waybill_departure_confirm(waybillId_[0])
                    self.logger.info("发车确认返回结果:{0}".format(
                        response_departure_confirm.json()))
                    response_ = WayBillCreate().waybill_create(
                        carType, applyDate, project['projectName'],
                        project['projectId'], supplier['name'],
                        supplier['supplierId'], outCar['name'], outCar['idNo'],
                        outCar['mobile'], outCar['carNo'], outCar['carLength'],
                        outCar['carModel'], photoAirWay, outCar['loginId'],
                        sendProvince, sendCity, sendDistrict, arriveProvince,
                        arriveCity, arriveDistrict, income, totalAmt, preAmt,
                        oilAmt, destAmt, lastAmt, hasReceipt, content, source,
                        cargoName, cargoWeight, cargoVolume,
                        cargoNumberOfCases, cargoWorth, insuranceCosts,
                        handlingFee, deliveryFee, oilCardDeposit, otherFee,
                        upWayBillId, oilCardNo, driver_info['vehicleIdNo'],
                        driver_info['cardNo'], driver_info['driverCardBank'],
                        driver_info['accountName'])
                    self.logger.info("公司车发车确认后,再次录单返回结果:{0}".format(
                        response_.json()))
                    waybillId = response_.json()['content']
                    return waybillId, outCar['mobile'],outCar['name'],outCar['idNo'],outCar['carNo'],outCar['carLength'],\
                           outCar['carModel'],project['projectName'], project['projectId'],supplier['name'], \
                           supplier['supplierId']
                else:
                    self.logger.info("创建外请车运单公共模块失败")
                    return None, None, None, None, None, None, None, None, None, None, None
            else:
                self.logger.error('外请车类型错误: {0}'.format(carType))
                return None, None, None, None, None, None, None, None, None, None, None
        except Exception as e:
            self.logger.error('新增运单公共模块发生异常:{0}'.format(e))
            return None