# -*- encoding=utf8 -*-
from common.common_func import commonFuc
from common.timeUtils import timeUtils
from common.fileUtls import FileUtils
from common.common_func import commonFuc, using
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
import sys

__author__ = "xiaohesheng"

"""
case_tag:api,mdm-web,a7产品信息审核批量_通过,id2251,id2251-7-2,sit,on,2023091201
主数据平台:a7产品信息审核批量_通过
"""
module = "a5_mdm3_pdm"
def test1():
    module = "a5_mdm3_pdm"
    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,username=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()
    """
     场景:a7产品信息审核批量_通过
     用例名称：a7产品信息审核批量_通过
     输入：CRid
     输出："rtn_msg": "ok"
    """
    # 登录
    username = h_name
    password = commonFuc().get_business_data(module, "password")
    print(username, password)
    # 获取token和projectCode
    token, projectCode, uxid, corpId,info = login_system(username, password).get_token()
    # 审批产品驳回
    url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "batchAuditByGoodsCert_url")
    # 获取请求头信息
    headers = commonFuc().get_business_data(module, "json_headers2",
                                            commonFuc().get_business_data(module, "json_contentType"), token,
                                            projectCode)
    info = FileUtils().r_info6(module, "产品审核信息",'message2')
    print(info)
    MSPid = info['MSPid']
    hosId = info['hosId']
    hosGoodsId = info['hosGoodsId']
    provGoodsid = info['provGoodsid']
    goodsAuditBillId= info['goodsAuditBillId']
    targetId= info['targetId']

    request_body = commonFuc().get_business_data(module, "payload5",hosId,goodsAuditBillId)

    print('a7产品信息审核批量_通过', request_body)
    # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print("a7产品信息审核批量_通过,结果", result)
    checkDict=commonFuc().get_business_data(module,'checkDict3')
    commonFuc().check_result(checkDict,result)
test1()