# -*- encoding=utf8 -*-
from common.timeUtils import timeUtils
from common.fileUtls import FileUtils
import sys

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,产品信息审核查询,id2251,id2251-3,sit,on,2023091201
主数据平台:产品信息审核查询
"""
module = "mdm3_pim"
from common.common_func import commonFuc, using
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
pro_path=commonFuc().get_pro_path()
# sys.path.append(pro_path+r'\\air_case\\mdm3_pim\\a1分页查询供应商产品数据.air')
# using(pro_path+r'\\air_case\\mdm3_pim\\a1分页查询供应商产品数据.air')
# from a1分页查询供应商产品数据 import *
sys.path.append(pro_path+r'\\air_case\\mdm3_pim\\a2产品信息申报.air')
using(pro_path+r'\\air_case\\mdm3_pim\\a2产品信息申报.air')
from a2产品信息申报 import *

"""
 场景:产品信息审核查询
 用例名称：产品信息审核查询
 输入：CRid
 输出："rtn_msg": "ok"
"""
# 登录
username = global_var_cname
password = commonFuc().get_business_data(module, "password")
print(username, password)
# 获取token和projectCode
token, projectCode, uxid, corpId,info = login_system(username, password).get_token()
# 产品信息审核查询
module = "mdm3_pim"
# 产品信息审核查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "listAuditBillByPage_url")
# 获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers2",
                                        commonFuc().get_business_data(module, "json_contentType"), token,
                                        projectCode)
p_name = global_var_p_name
request_body = commonFuc().get_business_data(module, "payload7",p_name)

# print('产品信息审核查询请求体', request_body)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
# print("产品信息审核查询返回结果", result)
data = commonFuc().analysis_json('data', result)
total=commonFuc().analysis_json('total', data)
GRBid = commonFuc().analysis_json('id', data)
global_var_GRBid=GRBid
if total==1:
    commonFuc().check_text_exist(p_name, result)
    data = commonFuc().analysis_json('data', result)
else:
    commonFuc().check_text_exist(p_name+'error', result)
