{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "### 日期修复",
   "id": "3ae3e5496f3f8a45"
  },
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "import pandas as pd\n",
    "from datetime import datetime, timezone, timedelta, date, UTC\n",
    "from api import API\n",
    "api_instance = API()    \n",
    "\n",
    "df = pd.read_excel(r\"C:\\Users\\Administrator.DESKTOP-7IC2USJ\\Downloads\\门店日使用数据_20250605150559.xlsx\",sheet_name=\"Sheet4\")\n",
    "\n",
    "for index,row in df.iterrows():\n",
    "    create_time = row[\"门店创建时间\"]\n",
    "    #转换为 UTC 时间（减去 8 小时，并附加 UTC 时区） 本次-16\n",
    "    task_start_utc = create_time - timedelta(hours=16)\n",
    "    task_start_utc = task_start_utc.replace(tzinfo=timezone.utc)  # 显式标记为 UTC\n",
    "    # print(task_start_utc)\n",
    "    task_start_utc = task_start_utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n",
    "    \n",
    "    pay_load= {\n",
    "        \"api_key\": \"673457d6837e60a418e0e56b\",\n",
    "        \"entry_id\": \"67d636bb6212b7619a7a4231\",\n",
    "        \"data_id\": row[\"data_id\"],\n",
    "        \"data\":\n",
    "            {\"_widget_1742091963879\": {\"value\": task_start_utc}, }\n",
    "    }\n",
    "\n",
    "    api_instance.entry_data_update(pay_load)\n",
    "        "
   ],
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "import pandas as pd\n",
    "from datetime import datetime, timezone, timedelta\n",
    "import asyncio\n",
    "from api import API\n",
    "\n",
    "api_instance = API()\n",
    "df = pd.read_excel(r\"C:\\Users\\Administrator.DESKTOP-7IC2USJ\\Downloads\\门店日使用数据_20250605150559.xlsx\", sheet_name=\"Sheet4\")\n",
    "\n",
    "async def process_row(row):\n",
    "    create_time = row[\"门店创建时间\"]\n",
    "    task_start_utc = create_time - timedelta(hours=16)\n",
    "    task_start_utc = task_start_utc.replace(tzinfo=timezone.utc)\n",
    "    task_start_utc = task_start_utc.strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n",
    "\n",
    "    pay_load = {\n",
    "        \"api_key\": \"673457d6837e60a418e0e56b\",\n",
    "        \"entry_id\": \"67d636bb6212b7619a7a4231\",\n",
    "        \"data_id\": row[\"data_id\"],\n",
    "        \"data\": {\"_widget_1742091963879\": {\"value\": task_start_utc}}\n",
    "    }\n",
    "    await api_instance.entry_data_update(pay_load)\n",
    "\n",
    "async def main():\n",
    "    tasks = [process_row(row) for _, row in df.iterrows()]\n",
    "    await asyncio.gather(*tasks)\n",
    "\n",
    "asyncio.run(main())"
   ],
   "id": "74596d33a4541073",
   "outputs": [],
   "execution_count": null
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
