# -*- encoding=utf8 -*-
from air_case.public1.public1.public1 import *
from common.db.sql.sql_del_branch_info import delData
from common.fileUtls import FileUtils
from common.run_cmd_script import execute_command

__author__ = "xiaohesheng"

"""
case_tag:api,b6_spd3_core_business_flow_database_check,a_a4_流程四_基础模块设置,id2303,id2303-4,sit,on
主数据平台:a_a4_流程四_基础模块设置
python runner_test.py tag id2303-4 debug mdm3
"""

from common.common_func import commonFuc
from air_case.b1_herp3_login.登录内网系统.登录内网系统 import login_system
from airtest.core.api import using
import sys
import time

module = "b6_spd3_core_business_flow_database_check"


def check_basics_set_info():
    print('检查院区数据，科室数据，库房库区数据')
    # 获取实际值
    # 要验证的数据sql
    sql1 = "select * from mcms_branch_info order by create_time desc  LIMIT 1;"
    actual = check_mcms_pur_sql(sql1)
    print('actual', actual)
    id = get_id("select id from mcms_branch_info order by create_time desc  LIMIT 1;")
    branch_id = get_branch_id()
    if branch_id == id:
        print('ok')
        commonFuc().check_text_exist_result_text('succees', 'succees')
    else:
        commonFuc().check_text_exist_result_text('error', 'succees')
    hos_id = get_hosid()
    name = get_id("select name from mcms_branch_info order by create_time desc  LIMIT 1;")
    address = name
    create_time = get_create_time("select create_time from mcms_branch_info where id='%s';" % id)
    last_modified = get_create_time("select last_modified from mcms_branch_info where id='%s';" % id)
    username = commonFuc().get_business_data('b2_herp3_bs', "username")
    create_user = get_login_user_uxid_bydb(username)
    last_modified_user = create_user
    expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                             'check_mcms_branch_info', id, hos_id, name, address, create_time,
                                             create_user
                                             , 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')
    # 验证科室数据
    # 要验证的数据sql
    for i in range(4):
        sql1 = "select * from sys_org where branch_id='%s' order by create_time desc LIMIT 1 OFFSET %s;" % (
            branch_id, i)
        actual = check_mcms_pur_sql(sql1)
        print('actual', actual)
        id = get_id(
            "select id from sys_org where branch_id='%s' order by create_time desc LIMIT 1 OFFSET %s;" % (branch_id, i))
        pid = get_id("select pid from sys_org where branch_id='%s' order by create_time desc LIMIT 1 OFFSET %s;" % (
            branch_id, i))
        code = get_id("select code from sys_org where branch_id='%s' and id='%s';" % (branch_id, id))
        corp_id = get_hosid()
        last_update_datetime = get_create_time("select last_update_datetime from sys_org where id='%s';" % id)
        create_time = get_create_time("select create_time from sys_org where id='%s';" % id)
        last_modified = get_create_time("select last_modified from sys_org where id='%s';" % id)
        if i < 3:
            expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                     'check_dept_info' + str(i), id, pid, code, corp_id, branch_id,
                                                     last_update_datetime
                                                     , create_time, create_user, last_modified_user, last_modified)
        else:
            user_leader_id = get_login_user_uxid_bydb(
                FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
            expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                     'check_dept_info' + str(i), id, pid, code, corp_id, branch_id,
                                                     last_update_datetime
                                                     , create_time, create_user, last_modified_user, last_modified,
                                                     user_leader_id)

        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')
    # 检查库房数据
    # 要验证的数据sql
    for i in range(3):
        sql1 = "select * from mcms_stock_info where branch_id='%s' order by stock_level desc LIMIT 1 OFFSET %s;" % (
            branch_id, i)
        actual = check_mcms_pur_sql(sql1)
        print('actual', actual)
        id = get_id(
            "select id from mcms_stock_info where branch_id='%s' order by stock_level desc LIMIT 1 OFFSET %s;" % (
                branch_id, i))
        hos_id = get_hosid()
        pid = get_id(
            "select pid from mcms_stock_info where branch_id='%s' order by stock_level desc LIMIT 1 OFFSET %s;" % (
                branch_id, i))

        stock_code = get_id(
            "select stock_code from mcms_stock_info where branch_id='%s' and id='%s';" % (branch_id, id))
        corp_id = get_hosid()
        create_time = get_create_time("select create_time from mcms_stock_info where id='%s';" % id)
        last_modified = get_create_time("select last_modified from mcms_stock_info where id='%s';" % id)
        if i == 0:
            dept_id = get_id(
                "select id from sys_org   where branch_id='%s' order by create_time desc LIMIT 1 OFFSET 1;" % branch_id)
        elif i == 1:
            dept_id = get_id(
                "select id from sys_org   where branch_id='%s' order by create_time desc LIMIT 1 OFFSET 2;" % branch_id)
        else:
            dept_id = get_id(
                "select id from sys_org   where branch_id='%s' order by create_time desc LIMIT 1 OFFSET 3;" % branch_id)
        if i == 2:
            stock_name = get_branch_name()
            expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                     'check_mcms_stock_info' + str(i), id, hos_id, pid, branch_id,
                                                     stock_code, stock_name, dept_id, create_user, create_time,
                                                     last_modified,
                                                     last_modified_user
                                                     )
        else:
            expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                     'check_mcms_stock_info' + str(i), id, hos_id, pid, branch_id,
                                                     stock_code, dept_id, 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')
    # 检查新增的用户信息
    # 要验证的数据sql
    sql1 = "select * from sys_user order by create_time desc LIMIT 1 OFFSET 0;"
    actual = check_mcms_pur_sql(sql1)
    print('actual', actual)
    id = get_id(
        "select id from sys_user  order by create_time desc LIMIT 1 OFFSET 0;")
    hos_id = get_hosid()
    user_code = get_id(
        "select user_code from sys_user where id='%s';" % id)

    create_time = get_create_time("select create_time from sys_user where id='%s';" % id)
    last_modified = get_create_time("select last_modified from sys_user where id='%s';" % id)
    last_update_datetime = get_create_time("select last_update_datetime from sys_user where id='%s';" % id)
    corp_id = get_hosid()
    expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                             'check_sys_user', id, user_code, last_update_datetime, create_time,
                                             create_user, last_modified, last_modified_user, corp_id
                                             )

    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_dept_goods_info():
    print('检查科室添加产品信息')
    hos_id = get_hosid()
    branch_id=get_branch_id()
    hos_name = get_hosname()
    dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
    dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    username = commonFuc().get_business_data('b2_herp3_bs', "username")
    create_user = get_login_user_uxid_bydb(username)
    last_modified_user = create_user
    target_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']

    # 要验证的数据sql
    for i in range(5):
        print('===============第'+str(i)+'个产品信息================================')
        sql1 = "select * from mcms_dept_goods_info  where branch_id='%s' and dept_name='二级检验科002'   order by HOS_GOODS_ID desc LIMIT 1 OFFSET %s;" % (
            branch_id,i)
        actual = check_mcms_pur_sql(sql1)
        print('actual', actual)
        id = get_id(
            "select id from mcms_dept_goods_info  where branch_id='%s' and dept_name='二级检验科002'   order by HOS_GOODS_ID desc LIMIT 1 OFFSET %s;" % (
            branch_id,i))
        hos_goods_id = get_id(
            "select hos_goods_id from mcms_dept_goods_info  where id='%s';" % (
                id))
        if check_hos_goods_id(hos_goods_id) == True:
            commonFuc().check_text_exist_result_text('succees', 'succees')
        else:
            commonFuc().check_text_exist_result_text('error', 'succees')

        create_time = get_create_time("select create_time from mcms_dept_goods_info where id='%s';" % id)
        last_modified = get_create_time("select last_modified from mcms_dept_goods_info where id='%s';" % id)
        shelf_code=get_stockAreaId_new_fromDb(dept_name,2)
        if i==2 or i==3:
            pkg_def_id=get_id("select id from branch_goods_pkg_def where hos_goods_id='%s' and branch_id='%s';"%(hos_goods_id,branch_id))
            expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                     'check_mcms_dept_goods_info' + str(i), id, hos_id, hos_name,
                                                     dept_id,
                                                     hos_goods_id,pkg_def_id, target_dept_id, shelf_code, create_user, create_time,
                                                     last_modified, last_modified_user, branch_id
                                                     )
        else:
            expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                     'check_mcms_dept_goods_info' + str(i), id, hos_id, hos_name, dept_id,
                                                     hos_goods_id, target_dept_id, shelf_code, create_user, create_time,
                                                     last_modified, last_modified_user, branch_id
                                                     )

        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_branch_goods_pkg_def():
    hos_id = get_hosid()
    branch_id = get_branch_id()
    hos_name = get_hosname()
    dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
    dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
    username = commonFuc().get_business_data('b2_herp3_bs', "username")
    create_user = get_login_user_uxid_bydb(username)
    last_modified_user = create_user
    target_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']

    # 要验证的数据sql
    for i in range(5):
        sql1 = "select * from mcms_dept_goods_info  order by create_time desc LIMIT 1 OFFSET %s;" % (
            i)
        actual = check_mcms_pur_sql(sql1)
        print('actual', actual)
        id = get_id(
            "select id from mcms_dept_goods_info  order by create_time desc LIMIT 1 OFFSET %s;" % (
                i))
        hos_goods_id = get_id(
            "select hos_goods_id from mcms_dept_goods_info  where id='%s';" % (
                id))
        if check_hos_goods_id(hos_goods_id) == True:
            commonFuc().check_text_exist_result_text('succees', 'succees')
        else:
            commonFuc().check_text_exist_result_text('error', 'succees')

        create_time = get_create_time("select create_time from mcms_dept_goods_info where id='%s';" % id)
        last_modified = get_create_time("select last_modified from mcms_dept_goods_info where id='%s';" % id)
        shelf_code = get_stockAreaId_new_fromDb(dept_name, 2)
        if i == 2 or i == 3:
            pkg_def_id = get_id("select id from branch_goods_pkg_def where hos_goods_id='%s' and branch_id='%s';" % (
            hos_goods_id, branch_id))
            expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                     'check_mcms_dept_goods_info' + str(i), id, hos_id, hos_name,
                                                     dept_id,
                                                     hos_goods_id, pkg_def_id, target_dept_id, shelf_code, create_user,
                                                     create_time,
                                                     last_modified, last_modified_user, branch_id
                                                     )
        else:
            expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                     'check_mcms_dept_goods_info' + str(i), id, hos_id, hos_name,
                                                     dept_id,
                                                     hos_goods_id, target_dept_id, shelf_code, create_user, create_time,
                                                     last_modified, last_modified_user, branch_id
                                                     )

        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_hos_goods_id(hos_goods_id):
    print('检查产品信息')
    for i in range(1, 6):
        info = FileUtils().r_info8('b5_spd3_core_business_flow', "产品审核信息", 'message%s' % i)
        hosGoodsId = info['hosGoodsId']
        if hos_goods_id == hosGoodsId:
            return True
    return False

def check_sys_user_mgr_range():
    print('检查用户授权数据')
    hos_id = get_hosid()
    branch_id = get_branch_id()
    hos_name = get_hosname()
    username = commonFuc().get_business_data('b2_herp3_bs', "username")
    create_user = get_login_user_uxid_bydb(username)
    last_modified_user = create_user
    target_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']
    user_id=get_login_user_uxid_bydb(FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
    # 要验证的数据sql
    for i in range(4):
        sql1 = "select * from  sys_user_mgr_range where user_id='%s'  order by mgr_range_name desc LIMIT 1 OFFSET %s;" % (
            (user_id,i))
        actual = check_mcms_pur_sql(sql1)
        print('actual', actual)
        id = get_id(
            "select id from sys_user_mgr_range  where user_id='%s' order by mgr_range_name desc LIMIT 1 OFFSET %s;" % (
                user_id,i))
        corp_id=hos_id
        if i==0:
            mgr_range_id=FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']
            mgr_range_name=FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid1']
        elif i==1:
            mgr_range_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid4']
            mgr_range_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid4']
        elif i==2:
            mgr_range_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid2']
            mgr_range_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
        else:
            mgr_range_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid3']
            mgr_range_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid3']
        mgr_branch_id=branch_id
        mgr_branch_name=get_branch_name()
        create_time = get_create_time("select create_time from sys_user_mgr_range where id='%s';" % id)
        last_modified = get_create_time("select last_modified from sys_user_mgr_range where id='%s';" % id)
        ext_str1=mgr_branch_name
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'check_sys_user_mgr_range_info' + str(i), id, user_id, corp_id,
                                                 mgr_range_id,
                                                 mgr_range_name, mgr_branch_id, mgr_branch_name, create_user, create_time,
                                                 last_modified_user,
                                                  last_modified,ext_str1
                                                 )


        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_dept_leader():
    print('检查科室负责人')
    branch_id=get_branch_id()
    sql1 = "select * from sys_org where branch_id='%s' order by create_time desc LIMIT 1 OFFSET 3;" % (
        branch_id)
    actual = check_mcms_pur_sql(sql1)
    print('actual', actual)
    id = get_id(
        "select id from sys_org where branch_id='%s' order by create_time desc LIMIT 1 OFFSET 3;" % (branch_id))
    pid = get_id("select pid from sys_org where branch_id='%s' order by create_time desc LIMIT 1 OFFSET 3;" % (
        branch_id))
    code = get_id("select code from sys_org where branch_id='%s' and id='%s';" % (branch_id, id))
    corp_id = get_hosid()
    last_update_datetime = get_create_time("select last_update_datetime from sys_org where id='%s';" % id)
    create_time = get_create_time("select create_time from sys_org where id='%s';" % id)
    last_modified = get_create_time("select last_modified from sys_org where id='%s';" % id)
    username = commonFuc().get_business_data('b2_herp3_bs', "username")
    create_user = get_login_user_uxid_bydb(username)
    last_modified_user=create_user
    user_leader_id = get_login_user_uxid_bydb(
            FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
    version=get_id("select version from sys_org where id='%s';" % id)
    expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                             'check_dept_leader', id, pid, code, corp_id, branch_id,
                                             last_update_datetime,version
                                             , create_time, create_user, last_modified_user, last_modified,
                                             user_leader_id)

    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_StockArea():
    print('检查新增的库区数据')
    branch_id = get_branch_id()
    stock_name = get_branch_name() + "中心库房"
    stock_id = get_stockId_fromdb(stock_name)
    for i in range(4):
        sql1 = "select * from mcms_stock_shelf where  stock_id ='%s' order by shelf_code desc LIMIT 1 OFFSET %s;" % (
            stock_id,i)
        actual = check_mcms_pur_sql(sql1)
        print('actual', actual)
        id = get_id(
            "select id from mcms_stock_shelf  where stock_id ='%s' order by shelf_code desc LIMIT 1 OFFSET %s;" % (stock_id,i))
        dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid1']

        shelf_code = get_stockAreaId_new_fromDb(dept_name, 1)
        shelf_no="自动化测试"
        create_time = get_create_time("select create_time from mcms_stock_shelf where id='%s';" % id)
        last_modified = get_create_time("select last_modified from mcms_stock_shelf where id='%s';" % id)
        # username = commonFuc().get_business_data('b2_herp3_bs', "username")
        create_user = get_login_user_uxid_bydb(
            FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')['username1'])
        last_modified_user = create_user
        parent_id=get_id("select parent_id from mcms_stock_shelf where id='%s';" % id)
        expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
                                                 'check_mcms_stock_shelf'+str(i), id, stock_id, shelf_code, shelf_no, parent_id,
                                                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')
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_a4_流程四_基础模块设置.air')
using(pro_path + r'//air_case/b5_spd3_core_business_flow/a_a4_流程四_基础模块设置.air')
from a_a4_流程四_基础模块设置 import test1, test2, grants_user, add_StockArea

try:

    # ==============删除业务数据和报表数据
    test1()  # 参数2是新增院区后缀为6位数的参数1是老模式
    test2()  # 科室添加产品信息(产品是从外网同步过来的)
    dept_query_all()  # 科室查询，将科室id写入文件中
    time.sleep(6)
    # 检查院区数据，科室数据，库房，新增用户数据
    check_basics_set_info()
    time.sleep(6)
    # 检查mcms_dept_goods_info表数据，验证科室添加的产品信息
    check_mcms_dept_goods_info()
    grants_user()  # 给用户授权
    time.sleep(6)
    # 检查授权数据
    check_sys_user_mgr_range()
    set_dept_lead1()  # 设置一级科室负责人
    time.sleep(6)
    check_dept_leader()
    add_StockArea()  # 添加库区
    time.sleep(6)
    #检查库区数据
    check_StockArea()
    commonFuc().check_text_exist_result_text('succees', 'succees')
    print('=================流程四结束=================')
except Exception as e:
    print("发生异常：", str(e))
    commonFuc().check_text_exist_result_text('succees', 'error')
    print('基础设置出现问题,后续脚本必然无法走通,检查脚本或者数据')
    sys.exit(0)
