{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"### start to get data PK504B10100004349 from 2021-12-30 18:00:04 to 2021-12-30 18:15:04\n",
"# get data from 2021-12-30 18:00:04 to 2021-12-30 18:15:04......... \n",
"all data-getting done, bms_count is 41, gps_count is 0, system_count is 0, accum_count is 0 \n",
"\n"
]
}
],
"source": [
"\n",
"__author__ = 'lmstack'\n",
"#coding=utf-8\n",
"import os\n",
"import datetime\n",
"import pandas as pd\n",
"from LIB.BACKEND import DBManager, Log\n",
"from sqlalchemy import create_engine\n",
"from sqlalchemy.orm import sessionmaker\n",
"import time, datetime\n",
"import dateutil.relativedelta\n",
"import traceback\n",
"from LIB.MIDDLE.CellStateEstimation.Common import log\n",
"from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload as DBDownload\n",
"import time, datetime\n",
"from pandas.core.frame import DataFrame\n",
"from apscheduler.schedulers.blocking import BlockingScheduler\n",
"from LIB.MIDDLE.SaftyCenter.DataDiag_Static.DataStatistics import DataSta\n",
"from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_CtrlSafty import CtrlSafty\n",
"from LIB.MIDDLE.SaftyCenter.DataDiag_Static.DiagDataMerge import DiagDataMerge\n",
"from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_SamplingSafty import SamplingSafty\n",
"from LIB.MIDDLE.SaftyCenter.DataDiag_Static.SC_BMSUploadError import BMSReportError\n",
"from LIB.MIDDLE.SaftyCenter.DataDiag_Static import CBMSBatDiag\n",
"from LIB.MIDDLE.SaftyCenter.Common import DBDownload as DBDw\n",
"from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam as QX_BatteryParam\n",
"from urllib import parse\n",
"import pymysql\n",
"\n",
"# 故障映射表\n",
"host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'\n",
"port=3306\n",
"db='algo_dict'\n",
"user='qx_algo_rw'\n",
"password=parse.quote_plus('qx@123456')\n",
"db_engine = create_engine(\n",
" \"mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8\".format(\n",
" user, password, host, port, db\n",
" ))\n",
"\n",
"errorcode_map = pd.read_sql(\"select * from faultcode_map\", db_engine)\n",
"db_engine.dispose()\n",
"sn = 'PK504B10100004349'\n",
"start_time = '2021-12-30 18:00:04'\n",
"end_time = '2021-12-30 18:15:04'\n",
"dbManager = DBManager.DBManager()\n",
"df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])\n",
"df_bms = df_data['bms']\n",
"df_bms=df_bms.dropna(subset=['总电流[A]'])\n",
"df_bms=df_bms.reset_index(drop=True)\n",
"df_Diag_Batdiag_update=BMSReportError.main(sn,df_bms,pd.DataFrame(),1,errorcode_map)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" start_time | \n",
" end_time | \n",
" product_id | \n",
" code | \n",
" level | \n",
" info | \n",
" advice | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2021-12-30 18:01:21 | \n",
" 2022-01-05 20:24:31 | \n",
" PK504B10100004349 | \n",
" B021 | \n",
" 0 | \n",
" | \n",
" | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" start_time end_time product_id code level \\\n",
"0 2021-12-30 18:01:21 2022-01-05 20:24:31 PK504B10100004349 B021 0 \n",
"\n",
" info advice \n",
"0 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_Diag_Batdiag_update"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'\n",
"port=3306\n",
"database='algo_dict'\n",
"user='qx_algo_readonly'\n",
"password='qx@123456'\n",
"\n",
"db_engine = create_engine(\"mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8\".format(user, password, host, port, database))\n",
"DbSession = sessionmaker(bind=db_engine)\n",
"\n",
"errorcode_map = pd.read_sql(\"select * from faultcode_map\", db_engine)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'\n",
"port=3306\n",
"db='algo_dict'\n",
"user='qx_algo_rw'\n",
"password=parse.quote_plus('qx@123456')\n",
"db_engine = create_engine(\n",
" \"mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8\".format(\n",
" user, password, host, port, db\n",
" ))\n",
"\n",
"errorcode_map2 = pd.read_sql(\"select * from faultcode_map\", db_engine)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" start_time | \n",
" end_time | \n",
" product_id | \n",
" code | \n",
" level | \n",
" info | \n",
" advice | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2021-12-30 18:01:21 | \n",
" 2021-12-30 21:55:31 | \n",
" PK504B10100004349 | \n",
" B021 | \n",
" 0 | \n",
" | \n",
" | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" start_time end_time product_id code level \\\n",
"0 2021-12-30 18:01:21 2021-12-30 21:55:31 PK504B10100004349 B021 0 \n",
"\n",
" info advice \n",
"0 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_Diag_Batdiag_update"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" id | \n",
" protocol | \n",
" end_errorcode | \n",
" platform_errorcode | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
" 1 | \n",
" 1 | \n",
" B003 | \n",
"
\n",
" \n",
" 1 | \n",
" 2 | \n",
" 1 | \n",
" 2 | \n",
" B006 | \n",
"
\n",
" \n",
" 2 | \n",
" 3 | \n",
" 1 | \n",
" 4 | \n",
" B009 | \n",
"
\n",
" \n",
" 3 | \n",
" 4 | \n",
" 1 | \n",
" 8 | \n",
" B012 | \n",
"
\n",
" \n",
" 4 | \n",
" 5 | \n",
" 1 | \n",
" 16 | \n",
" B015 | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 75 | \n",
" 99 | \n",
" 3 | \n",
" 163 | \n",
" B090 | \n",
"
\n",
" \n",
" 76 | \n",
" 100 | \n",
" 3 | \n",
" 164 | \n",
" B091 | \n",
"
\n",
" \n",
" 77 | \n",
" 101 | \n",
" 3 | \n",
" 68 | \n",
" B112 | \n",
"
\n",
" \n",
" 78 | \n",
" 102 | \n",
" 3 | \n",
" 69 | \n",
" B112 | \n",
"
\n",
" \n",
" 79 | \n",
" 103 | \n",
" 3 | \n",
" 1 | \n",
" B117 | \n",
"
\n",
" \n",
"
\n",
"
80 rows × 4 columns
\n",
"
"
],
"text/plain": [
" id protocol end_errorcode platform_errorcode\n",
"0 1 1 1 B003\n",
"1 2 1 2 B006\n",
"2 3 1 4 B009\n",
"3 4 1 8 B012\n",
"4 5 1 16 B015\n",
".. ... ... ... ...\n",
"75 99 3 163 B090\n",
"76 100 3 164 B091\n",
"77 101 3 68 B112\n",
"78 102 3 69 B112\n",
"79 103 3 1 B117\n",
"\n",
"[80 rows x 4 columns]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"errorcode_map2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "b3ba2566441a7c06988d0923437866b63cedc61552a5af99d1f4fb67d367b25f"
},
"kernelspec": {
"display_name": "Python 3.8.8 64-bit ('base': conda)",
"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.8.8"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}