# -*- encoding=utf8 -*-
import json
import traceback

from air_case.b1_herp3_login.登录内网系统.登录内网系统 import login_system
from air_case.public1.public1.public1 import *
from common.db.sql.sql_del_branch_info import delData
from common.db.sql.sql_tools import get_id, process_tuple

from common.fileUtls import FileUtils
from common.run_cmd_script import execute_command
from common.timeUtils import timeUtils
from airtest.core.api import using

__author__ = "xiaohesheng"

"""
case_tag:api,spd_core,a_b5流程十二请领业务流_二级库向二级库,id2302,id2302-15,sit,on
核心业务流:a_b5流程十二请领业务流_二级库向二级库
python runner_test.py tag id2302-15 debug mdm3
"""


def SERACH_goods_id(GoodsId):
    # 在请领出库渠道边仓中搜索产品
    module = 'b5_spd3_core_business_flow'
    # # 登录获取用户id等信息，使用创建的用户登录===========开始
    info = FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')
    username = info['username1']
    password = commonFuc().get_business_data("b2_herp3_bs", "password")
    print('username,password', username, password)
    # # 获取token和projectCode
    token, projectCode, uxid, corpId, info = login(username, password, 2)
    # 登录获取用户id等信息，使用创建的用户登录============结束\
    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            commonFuc().get_business_data(module, "X-APP-CODE"))
    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                             "herpService_mcmsBranchGoodsInfo_page_url")
    dept1 = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']
    # hosGoodsId = FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message2')['hosGoodsId']
    # GoodsId = hosGoodsId.replace(get_hosid(), '')
    request_body = commonFuc().get_business_data(module, "payload53_2", GoodsId, get_hosid(), get_branch_id(), dept1)
    result = commonFuc().http_post(url, request_body, headers)
    branchGoodsId = commonFuc().analysis_json('id', commonFuc().analysis_json('data', commonFuc().analysis_json('data',
                                                                                                                result)))
    return branchGoodsId


def second_dept_Request(hosGoodsId, type):
    module = "b5_spd3_core_business_flow"
    # # 登录获取用户id等信息，使用创建的用户登录===========开始
    info = FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')
    username = info['username1']
    password = commonFuc().get_business_data("b2_herp3_bs", "password")
    print('username,password', username, password)
    # # 获取token和projectCode
    token, projectCode, uxid, corpId, info = login(username, password, 2)
    # 登录获取用户id等信息，使用创建的用户登录============结束
    # 我要请领_手工请领_列表查询===========================
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            commonFuc().get_business_data(module, "X-APP-CODE"))

    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                             "herpService_buy_queryGoodsInfoPage_url")
    print('我要请领_手工请领_列表查询=================', url)
    deptid2 = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid5']
    deptname2 = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid5']
    # 高值
    # hosGoodsId = FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message1')['hosGoodsId']
    GoodsId = hosGoodsId.replace(get_hosid(), '')
    # areaCode = get_stockAreaId_new(deptid2, deptname2, 2)
    areaCode =process_tuple(get_id("select shelf_code from mcms_stock_shelf where address='二级科室005'and shelf_name='默认库区'order by create_time desc LIMIT 1;"))
    request_body = commonFuc().get_business_data(module, "payload39", GoodsId, get_hosid(), deptid2, areaCode)
    print('我要请领_手工请领_列表查询', 'request_body', request_body)
    result = commonFuc().http_post(url, request_body, headers)
    print('我要请领_手工请领_列表查询,result', result)
    data1 = commonFuc().analysis_json('data', commonFuc().analysis_json('data', result))
    goodsName = commonFuc().analysis_json('goodsName', data1)
    goodsSpec = commonFuc().analysis_json('goodsSpec', data1)
    mdmGoodsCode = commonFuc().analysis_json('mdmGoodsCode', data1)
    goodsCode = commonFuc().analysis_json('goodsCode', data1)
    unit = commonFuc().analysis_json('unit', data1)
    purMode = commonFuc().analysis_json('purMode', data1)
    goodsMfrsName = commonFuc().analysis_json('goodsMfrsName', data1)
    unitName = commonFuc().analysis_json('unitName', data1)
    price = commonFuc().analysis_json('price', data1)
    deptId = commonFuc().analysis_json('deptId', data1)
    # areaCode=commonFuc().analysis_json('areaCode',data1)
    areaName = '默认库区'
    targetDeptId = commonFuc().analysis_json('targetDeptId', data1)
    targetDeptName = commonFuc().analysis_json('targetDeptName', data1)
    targetStockId = commonFuc().analysis_json('targetStockId', data1)
    targetStockName = commonFuc().analysis_json('targetStockName', data1)
    purModeText = commonFuc().analysis_json('purModeText', data1)
    goodsGeneralName = commonFuc().analysis_json('goodsGeneralName', data1)
    provName = commonFuc().analysis_json('provName', data1)
    pkgDefId = commonFuc().analysis_json('pkgDefId', data1)
    pkgDefName= commonFuc().analysis_json('pkgDefName', data1)
    # 信息写入文件
    list_a = []
    list_b = []
    list_c = []
    list_a.append(data1)
    list_b.append(data1)
    list_c.append(data1)
    # print('list_a', len(list_a), list_a)
    info = (list_a, list_b, list_c)
    titlename = ('list_a', 'list_b', 'list_c')
    FileUtils().w_info8(info, module, '二级库向二级库请领产品信息', titlename, 'message23')
    # 我要请领_手工请领_列表查询===========================
    # 添加到请领车=============================================
    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                             "herpService_buy_createBuyCar_url")
    print('添加到请领车=================', url)
    if type == 1:
        request_body = commonFuc().get_business_data(module, "payload40", hosGoodsId, purMode,goodsName, goodsSpec,
                                                     mdmGoodsCode,
                                                     goodsCode, unit, goodsMfrsName,pkgDefName, pkgDefId, unitName, price,
                                                     deptId,
                                                     areaCode, areaName, targetDeptId, targetDeptName, targetStockId,
                                                     targetStockName, purModeText, goodsGeneralName, provName)
    elif type == 2:
        request_body = commonFuc().get_business_data(module, "payload41", hosGoodsId, purMode,goodsName, goodsSpec,
                                                     mdmGoodsCode,
                                                     goodsCode, unit, goodsMfrsName, unitName, price, deptId,
                                                     areaCode, areaName, targetDeptId, targetDeptName, targetStockId,
                                                     targetStockName, purModeText, goodsGeneralName, provName)
    elif type == 3:
        request_body = commonFuc().get_business_data(module, "payload42", hosGoodsId, purMode,goodsName, goodsSpec,
                                                     mdmGoodsCode,
                                                     goodsCode, unit, goodsMfrsName,pkgDefName, pkgDefId, unitName, price,
                                                     deptId,
                                                     areaCode, areaName, targetDeptId, targetDeptName, targetStockId,
                                                     targetStockName, purModeText, goodsGeneralName, provName)
    request_body = get_process_list(request_body)
    print('添加到请领车', 'request_body', request_body)
    result = commonFuc().http_post(url, request_body, headers)
    print('添加到请领车,result', result)

    # 添加到请领车=============================================


def BuyCarSubmit():
    module = "b5_spd3_core_business_flow"
    # # # 登录获取用户id等信息，使用创建的用户登录===========开始
    info = FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')
    username = info['username1']
    password = commonFuc().get_business_data("b2_herp3_bs", "password")
    print('username,password', username, password)
    # # 获取token和projectCode
    token, projectCode, uxid, corpId, info = login(username, password, 2)
    # # 登录获取用户id等信息，使用创建的用户登录============结束
    # 我要请领_手工请领_列表查询===========================
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            commonFuc().get_business_data(module, "X-APP-CODE"))
    # 请领车查询===============================================
    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                             "herpService_buy_queryBuyCarPage_url")
    print('请领车查询=================', url)
    deptid2 = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid5']
    deptname2 = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid5']
    areaCode = get_stockAreaId_new_fromDb(deptname2, 2)
    request_body = commonFuc().get_business_data(module, "payload43", areaCode, get_hosid(), deptid2)

    print('请领车查询', 'request_body', request_body)
    result = commonFuc().http_post(url, request_body, headers)
    print('请领车查询,result', result)
    data = commonFuc().analysis_json('data', result)
    list_id = []
    for i in data:
        id = commonFuc().analysis_json('id', i)
        list_id.append(id)
    # 请领车查询===============================================
    # 请领车提交===============================================
    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                             "herpService_buy_validBuyCarSubmit_url")
    print('请领车提交=================', url)

    billExpdtDate = timeUtils().get_time_add(30, 2)
    print('billExpdtDate', billExpdtDate)
    request_body = commonFuc().get_business_data(module, "payload44", billExpdtDate, get_branch_id(), list_id[0],
                                                 list_id[1], list_id[2])

    print('请领车提交', 'request_body', request_body)
    result = commonFuc().http_post(url, request_body, headers)
    print('请领车提交,result', result)
    # 请领车提交===============================================
    # 创建领车交易=================================================
    # url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
    #                                                                          "herpService_validBuyCarSubmit_url")
    # print('创建领车交易=================', url)
    #
    # billExpdtDate = timeUtils().get_time_add(30, 2)
    # request_body = commonFuc().get_business_data(module, "payload44", billExpdtDate, get_branch_id(), list_id[0],
    #                                              list_id[1], list_id[2])
    #
    # print('创建领车交易', 'request_body', request_body)
    # result = commonFuc().http_post(url, request_body, headers)
    # print('validBuyCarSubmit', 'request_body', request_body)
    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                             "herpService_buy_createBuyBill_url")
    print('创建领车交易=================', url)

    billExpdtDate = timeUtils().get_time_add(30, 2)
    request_body = commonFuc().get_business_data(module, "payload44", billExpdtDate, get_branch_id(), list_id[0],
                                                 list_id[1], list_id[2])

    print('创建领车交易', 'request_body', request_body)
    result = commonFuc().http_post(url, request_body, headers)
    print('创建领车交易,result', result)
    currentTaskList = commonFuc().analysis_json('currentTaskList', commonFuc().analysis_json('data', result))
    businessNo_list=[]
    for i in currentTaskList:
        businessNo = commonFuc().analysis_json('businessNo', i)
        businessNo_list.append(businessNo)
    #将请领单号写入文件
    info = (businessNo_list[0],businessNo_list[1],businessNo_list[2])
    titlename = ('buy_NO1', 'buy_NO2','buy_NO3')
    FileUtils().w_info8(info, 'b5_spd3_core_business_flow', '二级库向二级库请领单号', titlename, 'message25')


def add_dept2():
    module = 'b2_herp3_bs'
    # 内网登录
    username = commonFuc().get_business_data(module, "username")
    # print('医院名称',username)
    password = commonFuc().get_business_data(module, "password")
    # print(username, password,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
    # 获取token和projectCode
    token, projectCode, uxid, corpId, info = login_system(username, password).get_token()
    # print( token,projectCode,uxid,corpId,info)
    # c3_新增科室_特殊科室_二级库房
    branch_id = FileUtils().r_info(module, '院区新增')["branch_id"]
    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module, "dept_insert_url")

    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            commonFuc().get_business_data(module, "X-APP-CODE"))

    # #请求体
    request_body = commonFuc().get_business_data(module, "payload15_2", get_branch_id(), get_hosid())
    print(request_body)
    # # # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print('result', result)


def add_new_deptinfo():
    module = "b2_herp3_bs"
    # 内网登录
    username = commonFuc().get_business_data(module, "username")
    # print('医院名称',username)
    password = commonFuc().get_business_data(module, "password")
    # print(username, password,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
    # 获取token和projectCode
    token, projectCode, uxid, corpId, info = login_system(username, password).get_token()
    # print( token,projectCode,uxid,corpId,info)
    # b9_科室管理_科室登记_科室查询
    branch_id = FileUtils().r_info(module, '院区新增')["branch_id"]
    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module, "deptPage_url")

    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            commonFuc().get_business_data(module, "X-APP-CODE"))
    # #请求体
    request_body = commonFuc().get_business_data(module, "payload13", branch_id)
    print(request_body)
    # # # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print('result', result)
    data = commonFuc().analysis_json('data', result)
    total = commonFuc().analysis_json('total', data)
    if total == 5:
        commonFuc().check_text_exist(0, result)
    else:
        commonFuc().check_text_exist('error', result)
    # 将deptid写入文件
    data1 = commonFuc().analysis_json('data', data)
    print('data1', data1)
    info = []
    for i in data1:
        deptid = commonFuc().analysis_json('id', i)
        info.append(deptid)
    titlename = ['deptid1', 'deptid2', 'deptid3', 'deptid4', 'deptid5']

    FileUtils().w_info8(info, module, '所有科室id', titlename, 'message6')
    info1 = []
    for i in data1:
        ename = commonFuc().analysis_json('ename', i)
        info1.append(ename)
    FileUtils().w_info8(info1, module, '所有科室name', titlename, 'message6')


def edit_goods_target(currentDeptId, targetDeptId):
    module = "b2_herp3_bs"
    # # 登录获取用户id等信息，使用创建的用户登录===========开始
    info = FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')
    username = info['username1']
    password = commonFuc().get_business_data("b2_herp3_bs", "password")
    print('username,password', username, password)
    # # 获取token和projectCode
    token, projectCode, uxid, corpId, info = login(username, password, 2)
    # 登录获取用户id等信息，使用创建的用户登录============结束
    url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module, "basic_mcmsDeptGoodsInfo_page_url")

    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            commonFuc().get_business_data(module, "X-APP-CODE"))

    # #请求体
    request_body = commonFuc().get_business_data(module, "payload58_13_1", currentDeptId, get_hosid())
    result = commonFuc().http_post(url, request_body, headers)
    print('科室产品列表查询', result)
    data1 = commonFuc().analysis_json('data', commonFuc().analysis_json('data', result))
    for i in data1:
        shelfCode = commonFuc().analysis_json('shelfCode', i)
        id1 = commonFuc().analysis_json('id', i)
        pkgDefId = commonFuc().analysis_json('pkgDefId', i)
        purMode = commonFuc().analysis_json('purMode', i)
        tbStatus = commonFuc().analysis_json('tbStatus', i)
        url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                                 "herpService_basic_mcmsDeptGoodsInfo_url")
        url = url + id1
        result = commonFuc().http_get(url, headers)
        print('获取产品详情信息', result)
        data2 = commonFuc().analysis_json('data', result)
        packetQty = commonFuc().analysis_json('packetQty', data2)
        url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                                 "basic_mcmsDeptGoodsInfo_updateById")
        if purMode == 60 or purMode == 10:  # 低值和试剂
            request_body = commonFuc().get_business_data(module, "payload58_10_1", id1, pkgDefId, targetDeptId,
                                                         shelfCode, packetQty,
                                                         tbStatus)
        elif purMode == 20:  # 高值
            request_body = commonFuc().get_business_data(module, "payload58_10_2", id1, targetDeptId,
                                                         shelfCode, tbStatus)
        print('编辑产品请领渠道request_body', request_body)
        result = commonFuc().http_post(url, request_body, headers)
        print('编辑产品请领渠道result', result)


def pick_execute():
    module = "b5_spd3_core_business_flow"
    # # 登录获取用户id等信息，使用创建的用户登录===========开始
    info = FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')
    username = info['username1']
    password = commonFuc().get_business_data("b2_herp3_bs", "password")
    print('username,password', username, password)
    # # 获取token和projectCode
    token, projectCode, uxid, corpId, info = login(username, password, 2)
    # 登录获取用户id等信息，使用创建的用户登录============结束
    # 生成拣货单列表查询===============================================
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            commonFuc().get_business_data(module, "X-APP-CODE"))
    url1 = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                              "herpService_stock_out_buyPage_url")
    info=  FileUtils().r_info8('b5_spd3_core_business_flow', "二级库向二级库请领单号", 'message25')
    # print(info)
    DRNo_list = []
    for i in range(1,4):
        if i==1:
            orderNo = info['buy_NO1']
        elif i==2:
            orderNo = info['buy_NO2']
        elif i==3:
            orderNo = info['buy_NO3']
        else:
            orderNo='orderNo'
        print('请领出库列表页面=================', url1)
        request_body1 = commonFuc().get_business_data(module, "payload46_1", orderNo,get_branch_id())

        print('请领出库列表页面', 'request_body', request_body1)
        result1 = commonFuc().http_post(url1, request_body1, headers)
        print('请领出库列表页面,result1', result1)
        data1 = commonFuc().analysis_json('data', commonFuc().analysis_json('data', result1))
        for i in data1:
            # 获取id
            BH_ID = commonFuc().analysis_json('id', i)
            version = commonFuc().analysis_json('version', i)
            deptBuyDetailVOList = commonFuc().analysis_json('deptBuyDetailVOList', i)
            billMode = commonFuc().analysis_json('billMode', data1)
            # 生成拣货单列表查询===============================================
            # 生成拣货单列表锁定===============================================

            url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                                     "herpService_stock_out_use_updateLock_url")
            print('请领出库列表列表页面锁定=================', url)
            # version=int(version)+1
            request_body = commonFuc().get_business_data(module, "payload49_1", BH_ID, version)

            print('请领出库列表列表页面锁定', 'request_body', request_body)
            result = commonFuc().http_post(url, request_body, headers)
            print('请领出库列表列表页面锁定,result1', result)
            # 生成拣货单列表锁定===============================================

            # 拣货==============================
            if billMode == '16':
                udi_code = get_udi2(1)  # 获取条码 低值1 高值2 试剂3
            elif billMode == '20':
                udi_code = get_udi2(2)  # 获取条码 低值1 高值2 试剂3
            elif billMode == '66':
                udi_code = get_udi2(3)  # 获取条码 低值1 高值2 试剂3
            else:
                udi_code = 'udi_code'
            print('udi_code', udi_code)
            if billMode == '16':
                targetAreaCode,sourceId=pickScan2(BH_ID, udi_code, 1)  # 低值
            elif billMode == '20':
                targetAreaCode,sourceId=pickScan2(BH_ID, udi_code, 2)  # 高值
            elif billMode == '66':
                targetAreaCode,sourceId= pickScan2(BH_ID, udi_code, 3)  # 试剂
            else:
                targetAreaCode='targetAreaCode'
                sourceId='sourceId'
            # 提交领用出库单
            url = commonFuc().get_api_add_port_url() + commonFuc().get_business_data(module,
                                                                                     "herpService_stock_out_use_submit_url")
            print('提交拣货执行单=================', url)
            if billMode == '16':
                request_body = commonFuc().get_business_data(module, "payload51_1_1", targetAreaCode,sourceId)
            elif billMode == '20':
                request_body = commonFuc().get_business_data(module, "payload51_1_2", targetAreaCode,sourceId)
            elif billMode == '66':
                request_body = commonFuc().get_business_data(module, "payload51_1_3", targetAreaCode,sourceId)

            print('提交拣货执行单', 'request_body', request_body)
            result = commonFuc().http_post(url, request_body, headers)
            print(' 提交拣货执行单,result1', result)
            DR_id=commonFuc().analysis_json('data',result)

            DRNo_list.append(DR_id)
            # 将请领单号写入文件
    info = (DRNo_list[0], DRNo_list[1], DRNo_list[2])
    titlename = ('DR_NO1', 'DR_NO2', 'DR_NO3')
    FileUtils().w_info8(info, 'b5_spd3_core_business_flow', '拣货单id', titlename, 'message26')


# 复核===================================
def main():
    try:
        # ================暂时注释======================
        add_dept2()  # 新增一个二级科室
        add_new_deptinfo()  # 写入科室信息到文件中
        grants_user_new()  # 新增授权
        # 同步库房信息
        execute_command("python runner_test.py tag id2263-221 debug sit")
        # 设置部门用户
        set_dept_user(FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid5'],
                      FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid5'], 2)
        # 设置部门负责人
        set_dept_lead_new(FileUtils().r_info8('b2_herp3_bs', '所有科室id', 'message6')["deptid5"])  # 设置二级科室负责人
        get_stockAreaId_new(FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid5'],
                            FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid5'], 2)
        deptName5=FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid5']

        set_stockShelf_Linkman(FileUtils().r_info8('b2_herp3_bs', '所有科室id', 'message6')["deptid5"],get_stockAreaId2_new_fromDb(deptName5,2))#设置库区联系人
        #新建科室产品分配
        dept_goods_distribute(FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid5'])
        #编辑产品请领目标为二级检验科002
        currentDeptId = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid5']
        targetDeptId = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
        edit_goods_target(currentDeptId, targetDeptId)
        #================暂时注释=========================
        updateUserLoginDefaultRange(get_listUserMgrRangePage1(5))  # 设置登录账号默认权限是新二级库
        # # # 低值
        second_dept_Request(FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message2')['hosGoodsId'], 1)
        # # # 高值
        second_dept_Request(FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message1')['hosGoodsId'], 2)
        # # # 试剂
        second_dept_Request(FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message3')['hosGoodsId'], 3)
        BuyCarSubmit()  # 请领车提交
        for i in range(6):  # 三个单据共审批6次
            approval_center()
        updateUserLoginDefaultRange(get_listUserMgrRangePage1(2))  # 设置登录账号默认权限是二级库
        # 二级科室领用出库
        # 低值拣货执行
        pick_execute()
        second_dept_one_key_in(5)
        second_dept_one_key_in(5)
        second_dept_one_key_in(5)
        commonFuc().check_text_exist_result_text('succees', 'succees')
        print('================流程十二执行完毕===================')

    except:
        commonFuc().check_text_exist_result_text('error', '1')
# main()