更新埃森哲目录结构

This commit is contained in:
workpc 2025-03-27 10:08:59 +08:00
parent e9d80be5e8
commit 1a80dbb9a0
21 changed files with 199 additions and 3578 deletions

View File

@ -14,6 +14,7 @@
"import time\n",
"import pandas as pd\n",
"pd.set_option('display.max_columns', None)\n",
"import datetime\n",
"\n",
"import numpy as np\n",
"# 变量定义\n",
@ -21,6 +22,7 @@
"# query_data_list_item_nos_url\n",
"search_url = \"http://10.200.32.39/jingbo-api/api/warehouse/dwDataItem/queryByItemNos\" #jingbo-dev/api/warehouse/dwDataItem/queryDataListItemNos\n",
"upload_url = \"http://10.200.32.39/jingbo-api/api/dw/dataValue/pushDataValueList\"\n",
"queryDataListItemNos_url = \"http://10.200.32.39/jingbo-api//api/warehouse/dwDataItem/queryDataListItemNos\"\n",
"\n",
"\n",
"query_data_list_item_nos_data = {\n",
@ -972,28 +974,125 @@
" # 保存新的xls文件\n",
" new_workbook.save(\"定性模型数据项12-11.xlsx\")\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"def get_queryDataListItemNos_value(token, url, dataItemNoList, dateStart, dateEnd):\n",
"\n",
" search_data = {\n",
" \"funcModule\": \"数据项\",\n",
" \"funcOperation\": \"查询\",\n",
" \"data\": {\n",
" \"dateStart\": dateStart,\n",
" \"dateEnd\": dateEnd,\n",
" \"dataItemNoList\": dataItemNoList # 数据项编码,代表 brent最低价和最高价\n",
" }\n",
" }\n",
"\n",
" headers = {\"Authorization\": token}\n",
" search_res = requests.post(url=url, headers=headers, json=search_data, timeout=(3, 5))\n",
" search_value = json.loads(search_res.text)[\"data\"]\n",
" if search_value:\n",
" return search_value\n",
" else:\n",
" return None\n",
"\n",
"\n",
"\n",
"def save_queryDataListItemNos_xls(data_df,dataItemNoList):\n",
"\n",
" current_year_month = datetime.datetime.now().strftime('%Y-%m')\n",
" grouped = data_df.groupby(\"dataDate\")\n",
"\n",
"\n",
" df_old = pd.read_excel('定性模型数据项12-11.xlsx')\n",
" df_old0 = df_old[:1]\n",
" result_dict = {df_old0.iloc[0][col] : col for col in df_old0.columns}\n",
" df_old1 = df_old[1:].copy()\n",
"\n",
" df_old1[\"日期\"] = pd.to_datetime(df_old1[\"日期\"])\n",
" # 删除日期列为本月的数据\n",
" df_old1 = df_old1[~df_old1[\"日期\"].dt.strftime('%Y-%m').eq(current_year_month)]\n",
" df_old1[\"日期\"] = df_old1[\"日期\"].dt.strftime('%Y-%m-%d')\n",
"\n",
"\n",
" list_data = []\n",
" for date, group in grouped:\n",
" dict_data = {\"日期\": date}\n",
" for index, row in group.iterrows():\n",
" dict_data[result_dict[row['dataItemNo']]] = row['dataValue']\n",
" list_data.append(dict_data)\n",
"\n",
" df_current_year_month = pd.DataFrame(list_data)\n",
" df_current_year_month\n",
"\n",
" df_merged = pd.concat([df_old0, df_old1, df_current_year_month], ignore_index=True)\n",
"\n",
" df_merged.to_excel('定性模型数据项12-11.xlsx', index=False)\n",
"\n",
"\n",
"\n",
"def queryDataListItemNos():\n",
" df = pd.read_excel('定性模型数据项12-11.xlsx')\n",
" dataItemNoList = df.iloc[0].tolist()[1:]\n",
"\n",
" token = getLogToken()\n",
" if not token:\n",
" return\n",
"\n",
" # 获取当前日期\n",
" current_date = datetime.datetime.now()\n",
"\n",
" # 获取当月1日\n",
" first_day_of_month = current_date.replace(day=1)\n",
"\n",
" # 格式化为 YYYYMMDD 格式\n",
" dateEnd = current_date.strftime('%Y%m%d')\n",
" dateStart = first_day_of_month.strftime('%Y%m%d')\n",
"\n",
" search_value = get_queryDataListItemNos_value(token, queryDataListItemNos_url, dataItemNoList, dateStart, dateEnd)\n",
" # print(\"search_value\",search_value)\n",
"\n",
"\n",
" data_df = pd.DataFrame(search_value)\n",
"\n",
" data_df[\"dataDate\"] = pd.to_datetime(data_df[\"dataDate\"])\n",
" data_df[\"dataDate\"] = data_df[\"dataDate\"].dt.strftime('%Y-%m-%d')\n",
" save_queryDataListItemNos_xls(data_df,dataItemNoList)\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"### 原始代码备份\n",
"\n",
"# if __name__ == \"__main__\":\n",
"if __name__ == \"__main__\":\n",
" pass\n",
"\n",
" # 需要单独运行放开\n",
" # start_1()\n",
" # start()\n",
"\n",
" # # 每天定时12点运行\n",
"\n",
" # 每天定时12点运行\n",
" # while True:\n",
" # # 获取当前时间\n",
" # current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
" # current_time_1 = time.strftime(\"%H:%M:%S\", time.localtime())\n",
"\n",
"\n",
" # # 获取当月的数据写入到指定文件\n",
" # queryDataListItemNos()\n",
"\n",
"\n",
" # # 判断当前时间是否为执行任务的时间点\n",
" # if current_time == \"12:00:00\":\n",
" # print(\"执行定时任务\")\n",

File diff suppressed because it is too large Load Diff