# -*- 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_tools import get_create_time, check_mcms_dept_buy_car_sql, get_mdm_goods_code1, get_dept_buy_id, \
    check_mcms_dept_buy_sql, get_mdm_goods_code, get_expdt_date, get_buyBillId, get_goods_code1, get_pkg_def_id, \
    get_login_user_uxid_bydb, get_buyOrderNo, check_mcms_pur_plan_sql, get_PICK_id, get_PICK_order_no, get_planBillId, \
    get_purOrderNo, get_purBillId, get_purBillDate2, get_distrBillId, get_distrOrderNo, get_pick_detail_id, \
    check_batch_id, check_barcode_id, get_account_date

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,b6_spd3_core_business_flow_database_check,a_b2流程九请领业务流_二级库向中心库,id23032,id2303-12,sit,on
核心业务流:a_b2流程九请领业务流_二级库向中心库
python runner_test.py tag id2303-12 debug mdm3
注意：如果二级库请领了，在中心库生成拣货单的时候看不到数据，原因是产品请领出库渠道不是中心库，
可以手工去把请领渠道修改成中心库
如果二级库请领了，在中心库生成拣货单无法成功，原因是中心库没库存了
脚本存在上下游的关系，下面的业务会修改出库渠道，如果调试脚本，注意这个因素的影响
"""
def check_mcms_dept_buy_car(type=1):
    hos_goods_id = 'hos_goods_id'
    if type == 1:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message2')["hosGoodsId"]
    elif type == 2:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message1')["hosGoodsId"]
    elif type == 3:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message3')["hosGoodsId"]
    branch_id = get_branch_id()
    # 获取create_time的值
    create_time = get_create_time(
        "select create_time from mcms_dept_buy_car where branch_id='%s'and hos_goods_id='%s'order by create_time desc LIMIT 1;" % (
            branch_id, hos_goods_id))
    print('create_time', create_time)
    id = get_id(
        "select id from mcms_dept_buy_car where branch_id='%s'and hos_goods_id='%s' order by create_time desc LIMIT 1;" % (
            branch_id, hos_goods_id))
    print('id', id)
    create_user = get_id(
        "select create_user from mcms_dept_buy_car where branch_id='%s'and hos_goods_id='%s' order by create_time desc LIMIT 1;;" % (
            branch_id, hos_goods_id))
    print('create_time', create_time, 'id', id)
    sql = """select * from mcms_dept_buy_car where branch_id='%s' and hos_goods_id='%s' order by create_time desc LIMIT 1;
             """ % (branch_id, hos_goods_id)
    # 要验证的sql，取自数据库的表中
    actual_value1 = check_mcms_dept_buy_car_sql(sql)
    print(actual_value1)
    deptid2 = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
    deptname2 = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    areaCode = get_stockAreaId_new_fromDb(deptname2, 2)
    areaName = '默认库区'
    # 读取文件中的信息
    info = FileUtils().r_info8('b5_spd3_core_business_flow', "二级库请领产品信息", 'message21')
    list_a = info['list_a']
    mdm_goods_code = get_mdm_goods_code1(hos_goods_id)
    pur_mode = commonFuc().analysis_json('purMode', list_a)
    goodsCode = commonFuc().analysis_json('goodsCode', list_a)
    pkgDefId = commonFuc().analysis_json('pkgDefId', list_a)
    pkgDefName = commonFuc().analysis_json('pkgDefName', list_a)
    last_modified_user = create_user
    last_modified = create_time
    # print('actual_value1',actual_value1)
    actual_value2 = get_process_list2(actual_value1)
    # print('actual_value2')
    # print( actual_value2)
    # prov_hos_goods_id = '8d6273b7bca84dd8aace12b9422d7fd6'
    expected_value2 = 'expected_value2'
    if type == 1 or type == 3:
        expected_value2 = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                        'check_mcms_dept_buy_car_low_value', id, get_hosid(), branch_id,
                                                        deptid2,
                                                        deptname2, areaCode, areaName, hos_goods_id, mdm_goods_code,
                                                        goodsCode, pur_mode, pkgDefId, pkgDefName
                                                        , create_user, create_time, last_modified, last_modified_user)
    elif type == 2:
        expected_value2 = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                        'check_mcms_dept_buy_car_high_value', id, get_hosid(),
                                                        branch_id,
                                                        deptid2,
                                                        deptname2, areaCode, areaName, hos_goods_id, mdm_goods_code,
                                                        goodsCode, pur_mode,
                                                        create_user, create_time, last_modified, last_modified_user)
    # print('expected_value2', expected_value2)
    # expected_value2=get_process_list2(expected_value2)
    actual_value2 = actual_value2.replace(" ", "")
    expected_value2 = expected_value2.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    result = (compare_text_index(actual_value2, expected_value2))
    print('result', result)
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')


# 检查二级库请领单审批前的主表数据
def check_mcms_dept_buy(type=16):
    branch_id = get_branch_id()
    sql = """select * from mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc  LIMIT 1;
                 """ % (branch_id, type)
    actual = check_mcms_dept_buy_sql(sql)
    print(actual)
    # 获取主键id
    sql = "select id from  mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc  LIMIT 1;" % (
        branch_id, type)
    id1 = get_dept_buy_id(sql)
    # 获取order_no
    sql1 = "select order_no from  mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % (
        branch_id, type)
    order_no1 = get_dept_buy_id(sql1)
    print(process_tuple(id1), process_tuple(order_no1))
    id1 = process_tuple(id1)
    order_no1 = process_tuple(order_no1)
    deptid2 = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
    deptname2 = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    target_stock_name = get_branch_name() + "中心库房"
    # target_dept_id=FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']

    # area_code = get_stockAreaId_new(deptid2, deptname2, 2)
    info = FileUtils().r_info8("b5_spd3_core_business_flow", "库区信息", 'message22')
    list_a = info['list_a']
    area_code = get_stockAreaId_new_fromDb(deptname2, 2)
    area_name = '默认库区'
    # 读取文件中的信息
    info = FileUtils().r_info8('b5_spd3_core_business_flow', "二级库请领产品信息", 'message21')
    list_a = info['list_a']
    target_dept_id = commonFuc().analysis_json('targetDeptId', list_a)
    target_dept_name = commonFuc().analysis_json('targetDeptName', list_a)
    pur_mode = commonFuc().analysis_json('purMode', list_a)
    goodsCode = commonFuc().analysis_json('goodsCode', list_a)
    pkgDefId = commonFuc().analysis_json('pkgDefId', list_a)
    pkgDefName = commonFuc().analysis_json('pkgDefName', list_a)

    bill_expdt_date = get_expdt_date(
        "select bill_expdt_date from  mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc  LIMIT 1;" % (
            branch_id, type))
    rec_user = get_login_user_uxid()
    # rec_addr='二级检验科002'
    create_user = rec_user
    create_time = get_create_time(
        "select create_time from  mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc  LIMIT 1;" % (
            branch_id, type))
    last_modified = get_create_time(
        "select last_modified from  mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc  LIMIT 1;" % (
            branch_id, type))
    last_modified_user = rec_user
    last_auditor = rec_user
    last_audit_time = get_create_time(
        "select last_audit_time from  mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc  LIMIT 1;" % (
            branch_id, type))
    rec_addr = deptname2
    dept_id1 = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']
    stock_name = get_branch_name() + "中心库房"
    target_stock_id = get_stockId_fromdb(stock_name)
    if type == 16:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_dept_buy1', id1, order_no1, get_hosid(), branch_id,
                                                 deptid2,
                                                 deptname2, area_code, area_name, target_dept_id, target_dept_name,
                                                 target_stock_id, target_stock_name, bill_expdt_date, rec_user,
                                                 rec_addr, create_user, create_time,
                                                 last_modified, last_modified_user)
    elif type == 20:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_dept_buy2', id1, order_no1, get_hosid(),
                                                 branch_id, deptid2,
                                                 deptname2, area_code, area_name, target_dept_id, target_dept_name,
                                                 target_stock_id, target_stock_name, bill_expdt_date, rec_user,
                                                 rec_addr, create_user, create_time,
                                                 last_modified, last_modified_user)
    else:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_dept_buy3', id1, order_no1, get_hosid(),
                                                 branch_id, deptid2,
                                                 deptname2, area_code, area_name, target_dept_id, target_dept_name,
                                                 target_stock_id, target_stock_name, bill_expdt_date, rec_user,
                                                 rec_addr, create_user, create_time,
                                                 last_modified, last_modified_user)

    print('expected', expected)
    print('aaaaaaaaaaaaaaaaa')
    actual_value1 = get_process_list2(actual)
    expected_value1 = get_process_list2(expected)
    actual_value2 = actual_value1.replace(" ", "")
    expected_value2 = expected_value1.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    print(compare_text_index(actual_value2, expected_value2))
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')


# 检查二级库请领单审批前的子表数据
def mcms_dept_buy_detail(type=16):
    branch_id = get_branch_id()
    # 获取主表主键
    sql = "select id from  mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc  LIMIT 1;" % (
        branch_id, type)
    id1 = process_tuple(get_dept_buy_id(sql))
    # 获取order_no
    sql1 = "select order_no from  mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % (
        branch_id, type)
    order_no1 = get_dept_buy_id(sql1)
    order_no1 = process_tuple(order_no1)
    # 子表sql
    sql1 = "select * from mcms_dept_buy_detail where pid='%s';" % id1
    # 从数据库中获取实际值
    actual = check_mcms_dept_buy_sql(sql1)
    print('actual', actual)
    if type == 16:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message2')["hosGoodsId"]
    elif type == 20:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message1')["hosGoodsId"]
    else:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message3')["hosGoodsId"]

    # print(hos_goods_id,process_tuple(hos_goods_id))

    # 获取子表id
    detail_id = get_id("select id from mcms_dept_buy_detail where pid='%s';" % id1)
    print('detail_id', detail_id)
    info = FileUtils().r_info8('b5_spd3_core_business_flow', "二级库请领产品信息", 'message21')
    list_a = info['list_a']
    mdm_goods_code = process_tuple(
        get_mdm_goods_code("select mdm_goods_code from mcms_goods_info  where id='%s';" % hos_goods_id))
    goods_code = process_tuple(
        get_mdm_goods_code("select hos_goods_code from mcms_goods_info  where id='%s';" % hos_goods_id))
    pkg_def_id = process_tuple(
        get_id("select pkg_def_id from mcms_pkg where hos_goods_id='%s' LIMIT 1;" % hos_goods_id))
    if pkg_def_id == 'None':
        print(pkg_def_id)
        pkg_def_id = pkg_def_id.replace("'", "")
        print(pkg_def_id)
    pkg_def_name = process_tuple(
        get_id("select pkg_def_name from mcms_pkg where hos_goods_id='%s' LIMIT 1;" % hos_goods_id))
    create_user = get_login_user_uxid()
    create_time = get_create_time("select create_time from  mcms_dept_buy_detail where pid='%s';" % id1)
    last_modified = create_time
    last_modified_user = create_user
    if type == 16:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_dept_buy_detail', detail_id, id1, order_no1, hos_goods_id,
                                                 mdm_goods_code, goods_code, pkg_def_id, pkg_def_name, create_user,
                                                 create_time, last_modified, last_modified_user)
    elif type == 20:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_dept_buy_detail1', detail_id, id1, order_no1, hos_goods_id,
                                                 mdm_goods_code, goods_code, pkg_def_id, pkg_def_name, create_user,
                                                 create_time, last_modified, last_modified_user)
    else:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_dept_buy_detail2', detail_id, id1, order_no1, hos_goods_id,
                                                 mdm_goods_code, goods_code, pkg_def_id, pkg_def_name, create_user,
                                                 create_time, last_modified, last_modified_user)

    actual_value1 = get_process_list2(actual)
    expected_value1 = get_process_list2(expected)
    actual_value2 = actual_value1.replace(" ", "")
    expected_value2 = expected_value1.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    result = (compare_text_index(actual_value2, expected_value2))
    print('result', result)
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')

def check_mcms_pick_detail(pid,type,order_no):
    branch_id = get_branch_id()
    print('拣货单子表检查')
    sql = " select * from  mcms_pick_detail where pid='%s';" % (
        pid)
    actual = check_mcms_dept_buy_sql(sql)
    print(actual)
    id=get_id("select id from  mcms_pick_detail where pid='%s';" % ( pid))
    source_id=get_buyBillId(branch_id,type)
    if type == 16:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message2')["hosGoodsId"]
    elif type == 20:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message1')["hosGoodsId"]
    else:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message3')["hosGoodsId"]
    mdm_goods_code=get_mdm_goods_code1(hos_goods_id)
    goods_code=get_goods_code1(hos_goods_id)
    pkg_def_id=get_pkg_def_id(hos_goods_id)
    picker_name=None
    picker=None
    create_user=get_login_user_uxid_bydb(FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
    create_time=get_create_time("select create_time from  mcms_pick_detail where pid='%s';" % (pid))
    last_modified=get_create_time("select last_modified from  mcms_pick_detail where pid='%s';" % (pid))
    last_modified_user=None
    if type == 16:

        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_pick_center_detail1', id,pid,order_no,source_id,hos_goods_id
                                                 ,mdm_goods_code,goods_code,pkg_def_id,picker,picker_name,
        create_user,create_time,last_modified,last_modified_user

                                                 )
    elif type == 20:
        pkg_def_id=None
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_pick_center_detail2', id,pid,order_no,source_id,hos_goods_id
                                                 ,mdm_goods_code,goods_code,pkg_def_id,picker,picker_name,
        create_user,create_time,last_modified,last_modified_user

                                                 )
    else:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_pick_center_detail3', id,pid,order_no,source_id,hos_goods_id
                                                 ,mdm_goods_code,goods_code,pkg_def_id,picker,picker_name,
        create_user,create_time,last_modified,last_modified_user

                                                 )

    print('expected', expected)
    print('aaaaaaaaaaaaaaaaa')
    actual_value1 = get_process_list2(actual)
    expected_value1 = get_process_list2(expected)
    actual_value2 = actual_value1.replace(" ", "")
    expected_value2 = expected_value1.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    print(compare_text_index(actual_value2, expected_value2))
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')
def check_mcms_pick(type=16):
    branch_id = get_branch_id()
    print('拣货单验证')
    sql = " select * from  mcms_pick where branch_id='%s' and bill_mode='%s'  order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, type)
    actual = check_mcms_dept_buy_sql(sql)
    print(actual)
    id = get_id(
        "select id from  mcms_pick where branch_id='%s' and bill_mode='%s'  order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, type))
    order_no = get_id(
        "select order_no from  mcms_pick where branch_id='%s' and bill_mode='%s'  order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, type))
    source_id = get_buyBillId(branch_id, type)
    dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']
    dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid1']
    stock_id = get_stockId_fromdb(get_branch_name() + '中心库房')
    area_code = get_stockAreaId_new_fromDb(dept_name, 1)
    target_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
    target_dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    target_stock_id = get_stockId_fromdb(target_dept_name + '库房')
    target_area_code = get_stockAreaId_new_fromDb(target_dept_name, 2)
    username = FileUtils().r_info8("b2_herp3_bs", "用户名信息", 'message3')['username1']
    reviewer = None
    review_date = None
    buyBillId = get_buyBillId(branch_id, type)
    pickOrderNo = order_no
    buyOrderNo = get_buyOrderNo(branch_id, type)
    pickBillId = id
    create_user =  get_login_user_uxid_bydb(FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
    create_time = get_expdt_date(
        "select create_time from  mcms_pick where branch_id='%s' and bill_mode='%s'  order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, type))
    last_modified = get_expdt_date(
        "select last_modified from  mcms_pick where branch_id='%s' and bill_mode='%s'  order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, type))
    last_modified_user=create_user
    picker = None
    picker_name = None
    if type == 16:
        #检查拣货单子表
        check_mcms_pick_detail(id,type,order_no)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_pick_center1', id, get_hosid(), get_branch_id(), order_no, source_id,
                                                 dept_id,
                                                 dept_name, stock_id, area_code, target_dept_id, target_dept_name,
                                                 target_stock_id, target_area_code, reviewer,
                                                 review_date, buyBillId, pickOrderNo, buyOrderNo, pickBillId,
                                                 create_user, create_time, last_modified, last_modified_user,picker, picker_name
                                                 )
    elif type == 20:
        # 检查拣货单子表
        check_mcms_pick_detail(id,type,order_no)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_pick_center2', id, get_hosid(), get_branch_id(), order_no, source_id,
                                                 dept_id,
                                                 dept_name, stock_id, area_code, target_dept_id, target_dept_name,
                                                 target_stock_id, target_area_code, reviewer,
                                                 review_date, buyBillId, pickOrderNo, buyOrderNo, pickBillId,
                                                 create_user, create_time, last_modified, last_modified_user,picker, picker_name
                                                 )
    else:
        # 检查拣货单子表
        check_mcms_pick_detail(id, type, order_no)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_pick_center3', id, get_hosid(), get_branch_id(), order_no, source_id,
                                                 dept_id,
                                                 dept_name, stock_id, area_code, target_dept_id, target_dept_name,
                                                 target_stock_id, target_area_code, reviewer,
                                                 review_date, buyBillId, pickOrderNo, buyOrderNo, pickBillId,
                                                 create_user, create_time, last_modified, last_modified_user,picker, picker_name
                                                 )

    print('expected', expected)
    print('aaaaaaaaaaaaaaaaa')
    actual_value1 = get_process_list2(actual)
    expected_value1 = get_process_list2(expected)
    actual_value2 = actual_value1.replace(" ", "")
    expected_value2 = expected_value1.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    print(compare_text_index(actual_value2, expected_value2))
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')

def check_mcms_psi_out(type=1):
    print('检查中心库出库单')
    if type == 1:
        bill_mode = 16
    elif type == 2:
        bill_mode = 20
    else:
        bill_mode = 66
    branch_id = get_branch_id()
    sql = "select * from  mcms_psi where source_branch_id='%s' and bill_mode='%s' and stock_kind='CK_QL'  order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, bill_mode)
    # 获取实际值
    actual = check_mcms_pur_plan_sql(sql)
    print('actual', actual)
    sql = "select id from  mcms_psi  where source_branch_id='%s' and bill_mode='%s' and stock_kind='CK_QL' order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, bill_mode)
    id = get_id(sql)
    sql = "select order_no from  mcms_psi  where source_branch_id='%s' and bill_mode='%s' and stock_kind='CK_QL' order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, bill_mode)
    order_no = get_id(sql)
    target_corp_id = get_hosid()
    target_branch_id =get_branch_id()
    target_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
    target_dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    stock_name = get_branch_name() + "中心库房"
    target_stock_id =get_stockId_fromdb(target_dept_name+'库房')
    target_area_code =get_stockAreaId_new_fromDb(target_dept_name, 2)
    source_id = get_PICK_id(branch_id, bill_mode)
    source_no = None
    source_repl_id = None
    source_corp_id = get_hosid()
    source_branch_id = get_branch_id()
    source_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']
    source_dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid1']
    source_stock_id = get_stockId_fromdb(get_branch_name()+'中心库房')
    source_area_code = get_stockAreaId_new_fromDb(source_dept_name, 1)
    accounter = None
    account_date = None
    buyBillId = get_buyBillId(branch_id, bill_mode)
    if type == 1:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message2')["hosGoodsId"]
    elif type == 2:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message1')["hosGoodsId"]
    else:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message3')["hosGoodsId"]
    pickOrderNo = get_PICK_order_no(branch_id, bill_mode)
    pickBillId = get_PICK_id(branch_id, bill_mode)
    planBillId = get_planBillId(hos_goods_id)
    psiOutBillId = id
    psiOutOrderNo =order_no

    buyOrderNo = get_buyOrderNo(branch_id, bill_mode)
    purOrderNo = get_purOrderNo(branch_id, bill_mode)
    purBillId = get_purBillId(branch_id, bill_mode)
    bill_relation_json = get_purBillDate2(branch_id, bill_mode)
    purBillDate = reGetString(bill_relation_json, r'purBillDate":"', r'""distrBillId')
    distrBillId = get_distrBillId(branch_id, bill_mode)
    distrOrderNo = get_distrOrderNo(branch_id, bill_mode)
    checkBillId = source_id
    sql = "select order_no from mcms_check where id='%s';" % checkBillId
    checkOrderNo = get_id(sql)
    psiInBillId = id
    psiInOrderNo = order_no
    create_user = get_login_user_uxid_bydb(FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
    create_time = get_create_time("select create_time from  mcms_psi where id='%s';" % id)
    last_modified = get_create_time("select last_modified from  mcms_psi where id='%s';" % id)
    last_modified_user = create_user
    if type == 1:
        # 检查子表
        check_mcms_psi_batch_out(id, type, order_no, source_id)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check', 'check_mcms_psi_out_1_1_0905', id,
                                                 order_no, target_corp_id, target_branch_id, target_dept_id,
                                                 target_dept_name, target_stock_id
                                                 , target_area_code, source_id, source_no, source_repl_id,
                                                 source_corp_id, source_branch_id, source_dept_id, source_dept_name
                                                 , source_stock_id, source_area_code, accounter, account_date,
                                                 buyBillId,pickOrderNo, buyOrderNo,pickBillId,
                                                 psiOutBillId, psiOutOrderNo,
                                                 create_user
                                                 , create_time, last_modified, last_modified_user)
    elif type == 2:
        check_mcms_psi_batch_out(id, type, order_no, source_id)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check', 'check_mcms_psi_out_1_2_0905', id,
                                                 order_no, target_corp_id, target_branch_id, target_dept_id,
                                                 target_dept_name, target_stock_id
                                                 , target_area_code, source_id, source_no, source_repl_id,
                                                 source_corp_id, source_branch_id, source_dept_id, source_dept_name
                                                 , source_stock_id, source_area_code, accounter, account_date,
                                                 buyBillId,pickOrderNo, buyOrderNo,pickBillId,
                                                 psiOutBillId, psiOutOrderNo,
                                                 create_user
                                                 , create_time, last_modified, last_modified_user)
    else:
        check_mcms_psi_batch_out(id, type, order_no, source_id)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check', 'check_mcms_psi_out_1_3_0905',id,
                                                 order_no, target_corp_id, target_branch_id, target_dept_id,
                                                 target_dept_name, target_stock_id
                                                 , target_area_code, source_id, source_no, source_repl_id,
                                                 source_corp_id, source_branch_id, source_dept_id, source_dept_name
                                                 , source_stock_id, source_area_code, accounter, account_date,
                                                 buyBillId,pickOrderNo, buyOrderNo,pickBillId,
                                                 psiOutBillId, psiOutOrderNo,
                                                 create_user
                                                 , create_time, last_modified, last_modified_user)
    # 对比预期值和实际值是否一致
    actual_value1 = get_process_list2(actual)
    expected_value1 = get_process_list2(expected)
    actual_value2 = actual_value1.replace(" ", "")
    expected_value2 = expected_value1.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    result = (compare_text_index(actual_value2, expected_value2))
    print('result', result)
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')


def check_mcms_psi_batch_out(DR_ID, type, order_no, source_id1):
    if type == 1:
        bill_mode = 16
    elif type == 2:
        bill_mode = 20
    else:
        bill_mode = 66
    branch_id = get_branch_id()
    sql = " select * from  mcms_psi_batch where pid='%s';" % (
        DR_ID)
    actual = check_mcms_dept_buy_sql(sql)
    print('actual', actual)
    batch_main_key = get_id("select id from mcms_psi_batch where pid='%s';" % DR_ID)
    pid = DR_ID
    # order_no = get_id("select order_no from mcms_psi_dept_batch where pid='%s';" % DR_ID)
    source_detail_id = get_pick_detail_id(branch_id,bill_mode)
    pick_detail_id = source_detail_id
    if type == 1:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message2')["hosGoodsId"]
    elif type == 2:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message1')["hosGoodsId"]
    else:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message3')["hosGoodsId"]
    mdm_goods_code = get_mdm_goods_code1(hos_goods_id)
    goods_code = get_goods_code1(hos_goods_id)
    pkg_def_id = get_pkg_def_id(hos_goods_id)
    picker_name = FileUtils().r_info8("b2_herp3_bs", "用户名信息", 'message3')['username1']
    picker = get_login_user_uxid_bydb(picker_name)
    source_batch_id = get_id("select source_batch_id from mcms_psi_batch where pid='%s';" % DR_ID)
    distrBillId = get_distrBillId(branch_id, bill_mode)
    target_batch_id = source_batch_id
    if check_batch_id(source_batch_id) == True:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        commonFuc().check_text_exist_result_text('error', 'succees')
    barcode_id = get_id("select barcode_id from mcms_psi_batch where pid='%s';" % DR_ID)
    if check_barcode_id(barcode_id) == True:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        commonFuc().check_text_exist_result_text('error', 'succees')
    dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    shelf_code = get_stockAreaId_new_fromDb(get_branch_name(), 1)
    create_user = get_login_user_uxid_bydb(FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
    create_time = get_create_time("select create_time from  mcms_psi_batch where pid='%s';" % DR_ID)
    last_modified = get_create_time("select last_modified from  mcms_psi_batch where pid='%s';" % DR_ID)
    last_modified_user = create_user
    if type == 1:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_batch_out1_0905',  batch_main_key, pid, order_no, source_detail_id
                                                 , pick_detail_id,hos_goods_id, mdm_goods_code, goods_code, source_batch_id,
                                                 target_batch_id, barcode_id, shelf_code, create_user, create_time,
                                                 last_modified, last_modified_user

                                                 )
    elif type == 2:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_batch_out2_0905', batch_main_key, pid, order_no, source_detail_id
                                                 , pick_detail_id,hos_goods_id, mdm_goods_code, goods_code, source_batch_id,
                                                 target_batch_id, barcode_id, shelf_code, create_user, create_time,
                                                 last_modified, last_modified_user

                                                 )
    else:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_batch_out3_0905',  batch_main_key, pid, order_no, source_detail_id
                                                 , pick_detail_id,hos_goods_id, mdm_goods_code, goods_code, source_batch_id,
                                                 target_batch_id, barcode_id, shelf_code, create_user, create_time,
                                                 last_modified, last_modified_user

                                                 )

    print('expected', expected)
    print('aaaaaaaaaaaaaaaaa')
    actual_value1 = get_process_list2(actual)
    expected_value1 = get_process_list2(expected)
    actual_value2 = actual_value1.replace(" ", "")
    expected_value2 = expected_value1.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    print(compare_text_index(actual_value2, expected_value2))
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')

def check_mcms_psi_dept_in(type=16):
    branch_id = get_branch_id()
    sql = " select * from  mcms_psi_dept where target_branch_id='%s' and bill_mode='%s' and stock_kind='RK_QL' order by   CREATE_TIME desc LIMIT 1;" % (
    branch_id, type)
    actual = check_mcms_dept_buy_sql(sql)
    print(actual)

    if type == 16:
        source_id = process_tuple(get_id("select id from mcms_psi  where target_branch_id='%s'  and bill_mode='%s'  order by create_time desc  LIMIT 1;"%(branch_id,type)))
    elif type == 20:
        source_id = process_tuple(get_id("select id from mcms_psi  where target_branch_id='%s'  and bill_mode='%s'  order by create_time desc  LIMIT 1;"%(branch_id,type)))
    else:
        source_id = process_tuple(get_id("select id from mcms_psi  where target_branch_id='%s'  and bill_mode='%s'  order by create_time desc  LIMIT 1;"%(branch_id,type)))

    # source_id = ''.join(source_id)
    source_no=get_id("select order_no from  mcms_psi where id='%s';"%source_id)
    #获取入库单主键DR_ID
    sql = " select id from  mcms_psi_dept where target_branch_id='%s' and bill_mode='%s' and stock_kind='RK_QL' order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, type)
    DR_ID = get_id(sql)
    #获取order_no
    sql = " select order_no from  mcms_psi_dept where target_branch_id='%s' and bill_mode='%s' and stock_kind='RK_QL' order by   CREATE_TIME desc LIMIT 1;" % (
        branch_id, type)
    order_no = get_id(sql)
    target_corp_id = get_hosid()
    target_branch_id = get_branch_id()
    target_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
    target_dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    target_stock_id = get_stockId_fromdb(target_dept_name + '库房')
    target_area_code = get_stockAreaId_new_fromDb(target_dept_name, 2)
    PICK_id = get_PICK_id(branch_id, type)

    source_corp_id = get_hosid()
    source_branch_id = get_branch_id()
    source_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']
    source_dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid1']
    source_stock_id = get_stockId_fromdb(get_branch_name() + '中心库房')
    source_area_code = get_stockAreaId_new_fromDb(source_dept_name, 1)
    buyBillId = get_buyBillId(branch_id, type)
    pickOrderNo = get_PICK_order_no(branch_id, type)
    buyOrderNo = get_buyOrderNo(branch_id, type)
    pickBillId = get_PICK_id(branch_id, type)
    psiDeptOutBillId = source_id
    psiDeptOutOrderNo = source_no
    create_user = get_login_user_uxid_bydb(FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
    create_time = get_create_time("select create_time from  mcms_psi_dept where id='%s';" % DR_ID)
    last_modified = get_create_time("select last_modified from  mcms_psi_dept where id='%s';" % DR_ID)
    last_modified_user = create_user
    accounter=create_user
    sql="select account_date from  mcms_psi_dept where id='%s';"%DR_ID
    account_date=get_account_date(sql)
    psiDeptInBillId=DR_ID
    psiDeptInOrderNo=order_no
    if type == 16:
        # 子表检查
        check_mcms_psi_dept_batch_in(DR_ID,type,order_no,source_id)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_dept_in_1_0905', DR_ID, order_no, target_corp_id, target_branch_id,
                                                 target_dept_id, target_dept_name, target_stock_id
                                                 , target_area_code, source_id,source_no, source_corp_id, source_branch_id,
                                                 source_dept_id, source_dept_name, source_stock_id, source_area_code,
                                                 accounter,account_date,buyBillId, pickOrderNo, buyOrderNo, pickBillId, psiDeptOutBillId,
                                                 psiDeptOutOrderNo,psiDeptInBillId,psiDeptInOrderNo
                                                 , create_user, create_time, last_modified, last_modified_user

                                                 )
    elif type == 20:
        # 子表检查
        check_mcms_psi_dept_batch_in(DR_ID, type, order_no,source_id)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_dept_in_2_0905', DR_ID, order_no, target_corp_id, target_branch_id,
                                                 target_dept_id, target_dept_name, target_stock_id
                                                 , target_area_code, source_id,source_no, source_corp_id, source_branch_id,
                                                 source_dept_id, source_dept_name, source_stock_id, source_area_code,
                                                 accounter,account_date,buyBillId, pickOrderNo, buyOrderNo, pickBillId, psiDeptOutBillId,
                                                 psiDeptOutOrderNo,psiDeptInBillId,psiDeptInOrderNo
                                                 , create_user, create_time, last_modified, last_modified_user

                                                 )
    else:
        # 子表检查
        check_mcms_psi_dept_batch_in(DR_ID, type, order_no,source_id)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_dept_in_3_0905', DR_ID, order_no, target_corp_id, target_branch_id,
                                                 target_dept_id, target_dept_name, target_stock_id
                                                 , target_area_code, source_id,source_no, source_corp_id, source_branch_id,
                                                 source_dept_id, source_dept_name, source_stock_id, source_area_code,
                                                 accounter,account_date,buyBillId, pickOrderNo, buyOrderNo, pickBillId, psiDeptOutBillId,
                                                 psiDeptOutOrderNo,psiDeptInBillId,psiDeptInOrderNo
                                                 , create_user, create_time, last_modified, last_modified_user

                                                 )

    print('expected', expected)
    print('aaaaaaaaaaaaaaaaa')
    actual_value1 = get_process_list2(actual)
    expected_value1 = get_process_list2(expected)
    actual_value2 = actual_value1.replace(" ", "")
    expected_value2 = expected_value1.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    print(compare_text_index(actual_value2, expected_value2))
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')
def check_mcms_psi_dept_batch_in(DR_ID,type,order_no,source_id1):
    branch_id = get_branch_id()
    sql = " select * from  mcms_psi_dept_batch where pid='%s';" % (
        DR_ID)
    actual = check_mcms_dept_buy_sql(sql)
    print('actual', actual)
    batch_main_key = get_id("select id from mcms_psi_dept_batch where pid='%s';" % DR_ID)
    pid = DR_ID
    # order_no = get_id("select order_no from mcms_psi_dept_batch where pid='%s';" % DR_ID)
    source_detail_id = source_id1+'0001'
    pick_detail_id=None
    if type == 16:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message2')["hosGoodsId"]
    elif type == 20:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message1')["hosGoodsId"]
    else:
        hos_goods_id = FileUtils().r_info8('b5_spd3_core_business_flow', '产品审核信息', 'message3')["hosGoodsId"]
    mdm_goods_code = get_mdm_goods_code1(hos_goods_id)
    goods_code = get_goods_code1(hos_goods_id)
    pkg_def_id = get_pkg_def_id(hos_goods_id)
    picker_name = FileUtils().r_info8("b2_herp3_bs", "用户名信息", 'message3')['username1']
    picker = get_login_user_uxid_bydb(picker_name)
    source_batch_id=get_id("select source_batch_id from mcms_psi_dept_batch where pid='%s';" % DR_ID)
    target_batch_id=source_batch_id
    if check_batch_id(source_batch_id)==True:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        commonFuc().check_text_exist_result_text('error', 'succees')
    barcode_id=get_id("select barcode_id from mcms_psi_dept_batch where pid='%s';" % DR_ID)
    if check_barcode_id(barcode_id)==True:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        commonFuc().check_text_exist_result_text('error', 'succees')
    dept_name=FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    shelf_code= get_stockAreaId_new_fromDb(dept_name, 2)
    create_user = get_login_user_uxid_bydb(FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
    create_time = get_create_time("select create_time from  mcms_psi_dept_batch where pid='%s';" % DR_ID)
    last_modified = get_create_time("select last_modified from  mcms_psi_dept_batch where pid='%s';" % DR_ID)
    last_modified_user = None
    if type == 16:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_dept_batch_in1_0905', batch_main_key, pid, order_no,source_detail_id
                                            ,pick_detail_id,hos_goods_id,mdm_goods_code,goods_code,source_batch_id,
                                            target_batch_id,barcode_id,shelf_code,create_user,create_time,last_modified,
                                            last_modified_user

                                                 )
    elif type == 20:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_dept_batch_in2_0905', batch_main_key, pid, order_no,source_detail_id
                                            ,pick_detail_id,hos_goods_id,mdm_goods_code,goods_code,source_batch_id,
                                            target_batch_id,barcode_id,shelf_code,create_user,create_time,last_modified,
                                            last_modified_user

                                                 )
    else:
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'mcms_psi_dept_batch_in3_0905',batch_main_key, pid, order_no,source_detail_id
                                            ,pick_detail_id,hos_goods_id,mdm_goods_code,goods_code,source_batch_id,
                                            target_batch_id,barcode_id,shelf_code,create_user,create_time,last_modified,
                                            last_modified_user

                                                 )

    print('expected', expected)
    print('aaaaaaaaaaaaaaaaa')
    actual_value1 = get_process_list2(actual)
    expected_value1 = get_process_list2(expected)
    actual_value2 = actual_value1.replace(" ", "")
    expected_value2 = expected_value1.replace(" ", "")
    # print('actual_value2',actual_value2)
    print('expected_value2')
    print(expected_value2)
    print('actual_value2')
    print(actual_value2)
    print(compare_text_index(actual_value2, expected_value2))
    if actual_value2 == expected_value2:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        print('error')
        commonFuc().check_text_exist_result_text('error', 'succees')

pro_path = commonFuc().get_pro_path2()
print('pro_path', pro_path)
sys.path.append(pro_path + r'/air_case/b5_spd3_core_business_flow/a_b2流程九请领业务流_二级库向中心库.air')
using(pro_path + r'//air_case/b5_spd3_core_business_flow/a_b2流程九请领业务流_二级库向中心库.air')
from a_b2流程九请领业务流_二级库向中心库 import goods_move3, second_dept_Request, BuyCarSubmit, get_centeStock_pick_list_counts, \
    centeStock_pick,pick_execute

try:
    updateUserLoginDefaultRange(get_listUserMgrRangePage(2))  # 设置登录账号默认权限是二级库
    goods_move3()
    # 二级库区信息写入文件
    get_stockAreaId_new(FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2'],
                        FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2'], 2)
    deptName2 = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    # 设置库区联系人
    set_stockShelf_Linkman(FileUtils().r_info8('b2_herp3_bs', '所有科室id', 'message6')["deptid2"],
                           get_stockAreaId2_new_fromDb(deptName2, 2))
    # 低值
    second_dept_Request(FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message2')['hosGoodsId'], 1)
    check_mcms_dept_buy_car(1)
    # 高值
    second_dept_Request(FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message1')['hosGoodsId'], 2)
    check_mcms_dept_buy_car(2)
    # 试剂
    second_dept_Request(FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message3')['hosGoodsId'], 3)
    check_mcms_dept_buy_car(3)
    BuyCarSubmit()  # 请领车提交

    time.sleep(6)
    list_data = ['16', '20', '66']
    for i in list_data:
        check_mcms_dept_buy(int(i))
        mcms_dept_buy_detail(int(i))
    """
    这里的审批跟审批流的设置有关
    """
    for i in range(6):  # 三个单据共审批6次
         approval_center()
    updateUserLoginDefaultRange(get_listUserMgrRangePage(1))  # 设置登录账号默认权限是中心库
    # 获取拣货单列表个数
    for i in range(get_centeStock_pick_list_counts()):
        centeStock_pick()  # 中心库拣货
   # 检查拣货单表数据
    list_data = ['16', '20', '66']
    for i in list_data:
        check_mcms_pick(int(i))
    # 低值拣货执行
    hosGoodsId = FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message2')['hosGoodsId']
    GoodsId = hosGoodsId.replace(get_hosid(), '')
    pick_execute(hosGoodsId, GoodsId, 1)
    # 检查中心库出库单低值
    time.sleep(6)
    check_mcms_psi_out(1)

    # 高值拣货执行
    hosGoodsId = FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message1')['hosGoodsId']
    GoodsId = hosGoodsId.replace(get_hosid(), '')
    pick_execute(hosGoodsId, GoodsId, 2)
    # 检查中心库出库单高值
    time.sleep(6)
    check_mcms_psi_out(2)
    # 试剂拣货执行
    hosGoodsId = FileUtils().r_info8("b5_spd3_core_business_flow", "产品审核信息", 'message3')['hosGoodsId']
    GoodsId = hosGoodsId.replace(get_hosid(), '')
    pick_execute(hosGoodsId, GoodsId, 3)
    # 检查中心库出库单试剂
    time.sleep(6)
    check_mcms_psi_out(3)
    time.sleep(6)
    second_dept_one_key_in()
    second_dept_one_key_in()
    second_dept_one_key_in()
    time.sleep(6)
    # 检查入库单
    check_mcms_psi_dept_in(16)
    check_mcms_psi_dept_in(20)
    check_mcms_psi_dept_in(66)
    commonFuc().check_text_exist_result_text('succees', 'succees')
    print('==========================流程九结束==============================')
except Exception as e:
    # 打印错误信息
    print(f"发生错误: {e}")
    commonFuc().check_text_exist_result_text('error', 'succees')
