import datetime
import os
import time
import requests
from api import API
import re
from back_ground_module import CommonModule
import pandas as pd
from log_config import configure_task_logger, configure_error_task_logger
from tqdm import tqdm

api_instance = API()
common_module = CommonModule()
# start_time = datetime.datetime.now()

df = pd.read_excel(r"C:\Users\Administrator.DESKTOP-7IC2USJ\Downloads\经销商-新签服务单_20250722135012.xlsx",sheet_name="经销商-新签服务单")
for index,row in tqdm(df.iterrows()):
    data_id = row["data_id"]
    payload = {
        "data_id": data_id
    }
    res = api_instance.workflow_instance_get(payload)
    task_list = res.get("tasks")
    finish_time = ""
    for task in task_list:
        if task.get("title") == "审核环节":
            finish_time = task.get("finish_time")
            break

    payload = {
        "api_key":"673d8427549d00c3d753c530",
        "entry_id":"67c80eb3d2af9b9821928f45", # 日常回访
        "data_id": data_id,
        "data":{
            "_widget_1753162835213": {"value": finish_time}
        }
    }
    api_instance.entry_data_update(payload)

