# -*- 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,a3产品信息审核驳回,id2251,id2251-4-2,sit,on,2023091201
主数据平台:a3产品信息审核驳回
"""
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()

    sys.path.append(pro_path + r'\\air_case\\a5_mdm3_pdm\\a3产品信息审核_查询.air')
    using(pro_path + r'\\air_case\\a5_mdm3_pdm\\a3产品信息审核_查询.air')
    from a3产品信息审核_查询 import select1
    # select1()
    """
     场景:a3产品信息审核驳回
     用例名称：a3产品信息审核驳回
     输入：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, "singleAudit_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, "payload3",MSPid,hosId,hosGoodsId,provGoodsid,goodsAuditBillId,targetId)

    print('产品信息审核查询请求体', request_body)
    # 发送请求
    result = commonFuc().http_post(url, request_body, headers)
    print("产品信息审核驳回返回结果", result)
    checkDict=commonFuc().get_business_data(module,'checkDict')
    commonFuc().check_result(checkDict,result)
test1()
print('分割线====================================')
test1()