# -*- encoding=utf8 -*-
from airtest.core.helper import using

from common.common_func import commonFuc
from airtest.core.api import using
import sys
module = "a5_mdm3_pdm"

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,a2产品导入查询,id2251,id2251-2,sit,on,20231208
主数据平台:a2产品导入查询
"""

"""
 场景:a2产品导入查询
 用例名称：a2产品导入查询
 输入：CRid
 输出："rtn_msg": "ok"
"""
module = "a5_mdm3_pdm"
def goods_select():
    pro_path = commonFuc().get_pro_path()
    sys.path.append(pro_path + r'\\air_case\\a4_mdm3_cm\\a2供货关系申请_客户类型_医院_登录_企业登录.air')
    using(pro_path + r'\\air_case\\a4_mdm3_cm\\a2供货关系申请_客户类型_医院_登录_企业登录.air')
    from a2供货关系申请_客户类型_医院_登录_企业登录 import e_login
    token, projectCode, uxid, corpId, e_name = e_login()
    # 获取医院corpId
    sys.path.append(pro_path + r'\\air_case\\a4_mdm3_cm\\a1供货关系申请_客户类型_医院_登录_医院登录获取医院id.air')
    using(pro_path + r'\\air_case\\a4_mdm3_cm\\a1供货关系申请_客户类型_医院_登录_医院登录获取医院id.air')
    from a1供货关系申请_客户类型_医院_登录_医院登录获取医院id import h_login
    h_token, h_projectCode, h_uxid, h_corpId, h_name = h_login()

    # 分页查询供应商产品数据接口
    url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "queryImportTasksLst_url")
    print(url)
    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            projectCode)
    request_body = commonFuc().get_business_data(module, "payload1")

    # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print('实际值',result)
    code = commonFuc().analysis_json('code', result)
    data = commonFuc().analysis_json('data', result)
    total = commonFuc().analysis_json('total', data)
    # print('aaaaaaaaaaaaaaaaaaaaaaaaaaaa',data)
    # 断言实际结果中是否包含预期结果的内容
    # 新注册的企业首次查询产品信息，预期结果为空
    # check_dict = commonFuc().get_business_data(module, "checkDict")
    # print('预期值',check_dict)
    # commonFuc().check_text_exist(code, result)  # 检查验证码
    # commonFuc().check_text_exist('[]', result)  # 检查数据data为空[]
    if code==0 and total>=1:
        commonFuc().check_text_exist(code, result)  # 检查验证码
    else:
        commonFuc().check_text_exist('-1', result)
goods_select()