{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "31c0e11d-c87a-4e95-92a0-d1d09625e255", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "数据库连接成功 192.168.101.27 jingbo_test root\n" ] } ], "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": "a058f507", "metadata": {}, "outputs": [], "source": [ "login_pushreport_url = \"http://10.200.32.39/jingbo-api/api/server/login\"\n", "upload_url = \"http://10.200.32.39/jingbo-api/api/analysis/reportInfo/researchUploadReportSave\"\n", "upload_warning_url = \"http://10.200.32.39/jingbo-api/api/basicBuiness/crudeOilWarning/save\"\n", "query_data_list_item_nos_url = \"http://10.200.32.39/jingbo-api/api/warehouse/dwDataItem/queryDataListItemNos\"\n", "\n", "login_data = {\n", " \"data\": {\n", " \"account\": \"api_dev\",\n", " \"password\": \"ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=\",\n", " \"tenantHashCode\": \"8a4577dbd919675758d57999a1e891fe\",\n", " \"terminal\": \"API\"\n", " },\n", " \"funcModule\": \"API\",\n", " \"funcOperation\": \"获取token\"\n", "}" ] }, { "cell_type": "code", "execution_count": 4, "id": "8af0311d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'http://10.200.32.39/jingbo-api/api/server/login'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "login_pushreport_url" ] }, { "cell_type": "code", "execution_count": 5, "id": "2b330ee3-c006-4ab1-8558-59c51ac8d86f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'data': {'account': 'api_dev',\n", " 'password': 'ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=',\n", " 'tenantHashCode': '8a4577dbd919675758d57999a1e891fe',\n", " 'terminal': 'API'},\n", " 'funcModule': 'API',\n", " 'funcOperation': '获取token'}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "login_data" ] }, { "cell_type": "code", "execution_count": 6, "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": 7, "id": "22c0c7c4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'confirmFlg': False, 'data': {'accessToken': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfZGV2IiwidGgiOiI4YTQ1NzdkYmQ5MTk2NzU3NThkNTc5OTlhMWU4OTFmZSIsImx0IjoiYXBpIiwiaXNzIjoiIiwidG0iOiJQQyIsImV4cCI6MTczNTMxNTg5NywianRpIjoiNDk1NGEyNDYyYThkNDc1YjkwMTMwMDRjNGNlZWY4NTcifQ.ABXdVR-X4ZOtzPJN2slCa1HwqQgmwGjDxOX4aKqaBWU', 'md5Token': 'd870019072ff52333add0545d26398a8'}, 'status': True}\n" ] } ], "source": [ "token = get_head_auth_report()" ] }, { "cell_type": "code", "execution_count": 8, "id": "12077ead", "metadata": {}, "outputs": [], "source": [ "# token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfdGVzdCIsInRoIjoiOGE0NTc3ZGJkOTE5Njc1NzU4ZDU3OTk5YTFlODkxZmUiLCJsdCI6ImFwaSIsImlzcyI6IiIsInRtIjoiUEMiLCJleHAiOjE3MzE5NTkzNjUsImp0aSI6IjRiMjcwNTgzN2YyZDQxOWM4MzQ3NjI2NDQwZDlhZGQzIn0.PPgnoiJt412dJiceqVW8w7qkJFY4s-VqU9z6ZIkpqho'" ] }, { "cell_type": "code", "execution_count": 9, "id": "a7ae21d1", "metadata": {}, "outputs": [], "source": [ "# def upload_warning_data(warning_data):\n", "# token = get_head_auth_report()\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", "# if upload_res:\n", "# return upload_res\n", "# else:\n", "# logger.info(\"预警上传失败\")\n", "# return None\n", "\n", "\n", "# logger.info(f'上传预警信息')\n", "# try:\n", "# warning_date = datetime.datetime.now().strftime('%Y-%m-%d')\n", "# content = f'{warning_date}有2887个停更'\n", "# warning_data['data']['WARNING_DATE'] = warning_date\n", "# warning_data['data']['WARNING_CONTENT'] = content\n", "# upload_warning_data(warning_data)\n", "# logger.info(f'上传预警信息成功')\n", "# except Exception as e:\n", "# logger.error(f'上传预警信息失败:{e}')" ] }, { "cell_type": "code", "execution_count": 10, "id": "54942e1a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "
The requested URL was not found on this server. Sorry for the inconvenience.
\n",
"Please report this message and include the following information to us.
\n",
"Thank you very much!
URL: | \n", "http://10.200.32.39/jingbo-dev/api/warehouse/dwDataItem/queryDataListItemNos | \n", "
Server: | \n", "iz2zeb0rw4fi7a0b3dh8jfz | \n", "
Date: | \n", "2024/12/27 14:11:26 | \n", "