#coding=utf-8
import os
import datetime
import pandas as pd
from LIB.BACKEND import DBManager, Log
from LIB.MIDDLE import SignalMonitor
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import time, datetime
import traceback
from LIB.MIDDLE.LeakCurrent import LFPLeakCurrent20210812 as LFPLeakCurrent

from urllib import parse

dbManager = DBManager.DBManager()
if __name__ == "__main__":
    SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
    SNnums_6060=SNdata_6060['SN号']
    now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
    start_time=now_time-datetime.timedelta(days=31)
    end_time=str(now_time)
    start_time=str(start_time)

    for sn in SNnums_6060.tolist():
        res = LFPLeakCurrent.cal_LFPLeakCurrent(sn, end_time, start_time)
        res.to_csv('BMS_LeakCurrent_'+sn+'.csv',encoding='GB18030')