# -*- encoding=utf8 -*-
import random
import sys

from airtest.core.helper import using

from common.db.sql.sql_del_branch_info import delData
from common.db.sql.sql_del_kind_goodsinfo import delKindGoodsinfo
from common.db.sql.sql_del_notices_info import delByNoticeName
from common.fileUtls import FileUtils
from common.timeUtils import timeUtils
import threading

__author__ = "xiaohesheng"

"""
case_tag:api,herp-web,r_e2用户管理_角色管理_角色列表展示,id20250430,id20250412-id20250430,sit,on
内网:生成采购单
"""

from common.common_func import commonFuc
from air_case.b1_herp3_login.登录内网系统.登录内网系统 import login_system
import requests
import uuid
import json

module = "b2_herp3_bs"


def l_task():
    # 内网登录
    username = commonFuc().get_business_data(module, "username411")
    ## print('医院名称',username)
    password = commonFuc().get_business_data(module, "password411")
    # print(username, password,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
    # 获取token和projectCode
    token, projectCode, uxid, corpId, info = login_system(username, password).get_token()
    # print( token,projectCode,uxid,corpId,info)
    headers = commonFuc().get_business_data(module, "json_headers_pur", token)

    # 获取审批列表
    url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "wait_url")
    # print(url)
    request_body = commonFuc().get_business_data(module, "payload_wait")
    """
    场景: 审批
    """

    # 发送请求
    result = requests.post(url, json=request_body, headers=headers)
    # 获取接口响应时间
    result = json.loads(result.content)

    # 获取待审批任务信息
    for i in result["data"]["data"]:
        # 获取待审批任务id
        task_id = i["taskId"]
        # 审批
        url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "approval_url")
        # print(url)
        request_body = {
            "dtos": [
                {
                    "remark": "",
                    "taskId": task_id
                }
            ],
            "opinion": 1
        }
        # 发送请求
        result = requests.post(url, json=request_body, headers=headers)
        # 获取接口响应时间
        result = json.loads(result.content)
        print(result)


l_task()
