{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "31c0e11d-c87a-4e95-92a0-d1d09625e255", "metadata": {}, "outputs": [], "source": [ "from config_jingbo import *\n", "import requests\n", "import json\n", "import datetime" ] }, { "cell_type": "code", "execution_count": 2, "id": "83c81b9e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'http://192.168.100.53:8080/jingbo-dev/api/server/login'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "login_pushreport_url\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "2b330ee3-c006-4ab1-8558-59c51ac8d86f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'data': {'account': 'api_test',\n", " 'password': 'ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=',\n", " 'tenantHashCode': '8a4577dbd919675758d57999a1e891fe',\n", " 'terminal': 'API'},\n", " 'funcModule': 'API',\n", " 'funcOperation': '获取token'}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "login_data" ] }, { "cell_type": "code", "execution_count": 4, "id": "dcb6100a-ed2b-4077-a1a9-361c6cb565f9", "metadata": {}, "outputs": [], "source": [ "\n", "def get_head_auth_report():\n", " login_res = requests.post(url=login_pushreport_url, json=login_data, timeout=(3, 5))\n", " text = json.loads(login_res.text)\n", " print(text)\n", " if text[\"status\"]:\n", " token = text[\"data\"][\"accessToken\"]\n", " return token\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "22c0c7c4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'confirmFlg': False, 'data': {'accessToken': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfdGVzdCIsInRoIjoiOGE0NTc3ZGJkOTE5Njc1NzU4ZDU3OTk5YTFlODkxZmUiLCJsdCI6ImFwaSIsImlzcyI6IiIsInRtIjoiUEMiLCJleHAiOjE3MzIxMDcwNDUsImp0aSI6ImM0Njk5ZGY3YWYwMTQ1Y2I4NWUzYjJhZTg2ZjMzYzRiIn0.EuDSlyPRNA3ULUyNHCKpj2nZCCyRqpOY72A_qkoSkJs', 'md5Token': 'af20ab3fd063d5a7e1929d1e6d393f9e'}, 'status': True}\n" ] } ], "source": [ "token = get_head_auth_report()" ] }, { "cell_type": "code", "execution_count": 6, "id": "12077ead", "metadata": {}, "outputs": [], "source": [ "# token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfdGVzdCIsInRoIjoiOGE0NTc3ZGJkOTE5Njc1NzU4ZDU3OTk5YTFlODkxZmUiLCJsdCI6ImFwaSIsImlzcyI6IiIsInRtIjoiUEMiLCJleHAiOjE3MzE5NTkzNjUsImp0aSI6IjRiMjcwNTgzN2YyZDQxOWM4MzQ3NjI2NDQwZDlhZGQzIn0.PPgnoiJt412dJiceqVW8w7qkJFY4s-VqU9z6ZIkpqho'" ] }, { "cell_type": "code", "execution_count": 7, "id": "a7ae21d1", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "last_update_times_df = pd.read_csv(os.path.join(dataset,'last_update_times.csv'))\n", "\n", "y_last_update_time = '2024-11-18'\n", "warning_data_df = last_update_times_df[last_update_times_df['warning_date'] 0:\n", " content = '原油特征指标预警信息:\\n\\n'\n", " warning_data_df = warning_data_df.sort_values(by='停更周期',ascending=False)\n", " fixed_length = 30\n", " warning_data_df['特征名称'] = warning_data_df['特征名称'].str.replace(\" \", \"\")\n", " content = warning_data_df.to_string(index=False, col_space=fixed_length)\n", " \n", "else:\n", " logger.info(f'没有需要上传的预警信息')\n", " content = '没有需要维护的特征指标'\n", "warning_date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n", "warning_data['data']['WARNING_DATE'] = warning_date\n", "warning_data['data']['WARNING_CONTENT'] = content" ] }, { "cell_type": "code", "execution_count": null, "id": "b8009a67", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 8, "id": "3e1a9e67", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "预警上传中...\n", "token:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfdGVzdCIsInRoIjoiOGE0NTc3ZGJkOTE5Njc1NzU4ZDU3OTk5YTFlODkxZmUiLCJsdCI6ImFwaSIsImlzcyI6IiIsInRtIjoiUEMiLCJleHAiOjE3MzIxMDcwNDUsImp0aSI6ImM0Njk5ZGY3YWYwMTQ1Y2I4NWUzYjJhZTg2ZjMzYzRiIn0.EuDSlyPRNA3ULUyNHCKpj2nZCCyRqpOY72A_qkoSkJs\n", "warning_data:{'funcModule': '原油特征停更预警', 'funcOperation': '原油特征停更预警', 'data': {'WARNING_TYPE_NAME': '特征数据停更预警', 'WARNING_CONTENT': ' 停更周期 预警日期 最后更新时间 更新周期 特征名称\\n 2218 2018-10-27 2018-10-24 1.0 西北欧即期Brent211利润\\n 1023 2022-02-03 2022-01-31 1.0 B-W活跃合约价差\\n 1023 2022-02-03 2022-01-31 1.0 W-B活跃合约价差\\n 734 2022-11-19 2022-11-16 1.0 Brent/迪拜原油升贴水\\n 686 2023-01-06 2023-01-03 1.0 PVMDubaiEFS/SwapvsICEFirstMonthBrent\\n 446 2023-09-03 2023-08-31 1.0 美国RBOB期货2309月份合约价格\\n 293 2024-02-03 2024-01-31 1.0 美国墨西哥湾87#汽油现货价格\\n 265 2024-03-02 2024-02-28 1.0 Ebob连1合约\\n 223 2024-04-13 2024-04-10 1.0 中国航班执行数\\n 91 2024-08-23 2024-08-20 1.0 Kpler-海运在途原油\\n 86 2023-04-15 2023-03-31 7.0 原油:开工率:东北地区:独立炼厂(周)\\n 68 2023-08-19 2023-08-04 7.0 原油:港口库存:中国(周)\\n 30 2024-05-13 2024-04-28 7.0 中东-巴林周度原油海运出口\\n 26 2024-06-08 2024-05-24 7.0 原油:山东港口:库存:新口径(周)\\n 26 2024-06-08 2024-05-24 7.0 原油:山东港口:库存:新口径(周)超季节性/3年\\n 23 2024-06-29 2024-06-14 7.0 美国:炼油厂的投入与使用情况:开工率:当周值\\n 23 2024-06-29 2024-06-14 7.0 美国:墨西哥湾沿岸:炼油厂的投入与使用情况:开工率:当周值\\n 23 2024-06-29 2024-06-14 7.0 美国:洛基山地区:炼油厂的投入与使用情况:开工率:当周值\\n 23 2024-06-29 2024-06-14 7.0 美国:西海岸地区:炼油厂的投入与使用情况:开工率:当周值\\n 23 2024-06-29 2024-06-14 7.0 美国:东海岸地区:炼油厂的投入与使用情况:开工率:当周值\\n 23 2024-06-29 2024-06-14 7.0 美国:中西部地区:炼油厂的投入与使用情况:开工率:当周值\\n 22 2023-10-09 2023-08-27 21.0 中东-也门周度原油海运出口\\n 20 2024-11-02 2024-10-30 1.0 Brentc102:30收盘价滞后1天\\n 20 2024-11-02 2024-10-30 1.0 Brentc202:30收盘价滞后1天\\n 20 2024-11-02 2024-10-30 1.0 EFSc102:30收盘价滞后1天\\n 20 2024-11-02 2024-10-30 1.0 EFSc202:30收盘价滞后1天\\n 19 2024-11-03 2024-10-31 1.0 WTIc2-c3(结算B)\\n 19 2024-11-03 2024-10-31 1.0 Brentc2-c3(结算B)\\n 18 2024-08-05 2024-07-21 7.0 全球原油库存(剔除富查伊拉)\\n 13 2024-09-09 2024-08-25 7.0 Kpler-美国原油净进口(周度)\\n 8 2024-10-12 2024-09-27 7.0 美国墨西哥湾原油钻机数\\n 7 2024-10-19 2024-10-04 7.0 美国柴油产量占比\\n 7 2024-10-19 2024-10-04 7.0 美国汽油产量占比\\n 6 2024-11-16 2024-11-13 1.0 马瑞原油:重质:DES价:委内瑞拉(日)\\n 6 2024-11-16 2024-11-13 1.0 丙烷CFR华南/布伦特原油比价\\n 6 2024-11-16 2024-11-13 1.0 国内马瑞与SC比价\\n 6 2024-11-16 2024-11-13 1.0 马瑞原油:现货价:山东(日)\\n 5 2024-11-17 2024-11-14 1.0 OMAN原油:中质:远期现货DES价:山东(日)', 'WARNING_DATE': '2024-11-20 10:50:47'}}\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "{\"confirmFlg\":false,\"data\":true,\"status\":true}\n" ] } ], "source": [ "# def upload_warning_data(token, warning_data):\n", "warning_data = warning_data\n", "headers = {\"Authorization\": token}\n", "logger.info(\"预警上传中...\")\n", "logger.info(f\"token:{token}\")\n", "logger.info(f\"warning_data:{warning_data}\" )\n", "upload_res = requests.post(url=upload_warning_url, headers=headers, json=warning_data, timeout=(3, 15))\n", "print(upload_res.text)" ] }, { "cell_type": "code", "execution_count": null, "id": "1d47fe3c", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "0baedf8f-3f6a-47c6-808d-c3363662f90f", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }