lmstack 3 years ago
parent
commit
5fd7e37af5

+ 0 - 63
LIB/FRONTEND/LeakCurrent/create_table.py

@@ -1,63 +0,0 @@
-'''
-定义表的结构,并在数据库中创建对应的数据表
-'''
-__author__ = 'lmstack'
-
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, FLOAT, TIMESTAMP, func
-from urllib import parse
-Base = declarative_base()
-
-
-class ConsistencyDeltaSoc(Base):
-    __tablename__ = "consistency_leak_current"
-    __table_args__ = ({'comment': '电池一致性:漏电流'})  # 添加索引和表注释
-
-    id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
-    add_time = Column(TIMESTAMP(True), server_default=func.now()) # 创建时间
-    update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now()) # 更新时间
-    sn = Column(String(64), comment="sn")
-    time = Column(DateTime, comment="时间")
-    cell1 = Column(FLOAT, comment="cell1")
-    cell2 = Column(FLOAT, comment="cell2")
-    cell3 = Column(FLOAT, comment="cell3")
-    cell4 = Column(FLOAT, comment="cell4")
-    cell5 = Column(FLOAT, comment="cell5")
-    cell6 = Column(FLOAT, comment="cell6")
-    cell7 = Column(FLOAT, comment="cell7")
-    cell8 = Column(FLOAT, comment="cell8")
-    cell9 = Column(FLOAT, comment="cell9")
-    cell10 = Column(FLOAT, comment="cell10")
-    cell11 = Column(FLOAT, comment="cell11")
-    cell12 = Column(FLOAT, comment="cell12")
-    cell13 = Column(FLOAT, comment="cell13")
-    cell14 = Column(FLOAT, comment="cell14")
-    cell15 = Column(FLOAT, comment="cell15")
-    cell16 = Column(FLOAT, comment="cell16")
-    cell17 = Column(FLOAT, comment="cell17")
-    cell18 = Column(FLOAT, comment="cell18")
-    cell19 = Column(FLOAT, comment="cell19")
-    cell20 = Column(FLOAT, comment="cell20")
-
-
-
-    # def __init__(self, sn, current, time_stamp, pack_state, line_state):
-    #     self.sn = sn
-    #     self.current = current
-    #     self.time_stamp = time_stamp
-    #     self.pack_state = pack_state
-    #     self.line_state = line_state
-
-# 执行该文件,创建表格到对应的数据库中
-if __name__ == "__main__":
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-    
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    Base.metadata.create_all(db_engine)

+ 0 - 91
LIB/FRONTEND/LeakCurrent/deploy_6060.py

@@ -1,91 +0,0 @@
-#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
-import pymysql
-import dateutil.relativedelta
-
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    
-    # 时间设置
-    now_time = datetime.datetime.now()
-    pre_time = now_time + dateutil.relativedelta.relativedelta(weeks=-2)
-    end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 09:00:00")
-    start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 09:00:00")
-    
-    # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei from app_device")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-    
-    
-    # 日志配置
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/6060/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='leak_current', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-    # SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
-    # SNnums_6060=SNdata_6060['SN号']
-    # # SNnums_6060 = ['PK504B00100004019','PK504B00100004029', 'PK504B00100004080', 'PK504B00100004264', 'PK504B10100004331']
-    # now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
-    # now_time = "2021-08-01 00:00:00" # 定时任务开启时,需要删除改行!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-    # now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
-    # start_time=now_time-datetime.timedelta(days=1000)
-    # end_time=str(now_time)
-    # start_time=str(start_time)
-    for i in range(0, len(df_sn)):
-        try:
-            if df_sn.loc[i, 'imei'][6:9] != '660':
-                continue
-            sn = df_sn.loc[i, 'sn']
-            logger.info("pid-{} 6060 SN: {} START!".format(os.getpid(), sn))
-            res = LFPLeakCurrent.cal_LFPLeakCurrent(sn, end_time, start_time)
-            if not res.empty:
-                res.columns = ['time', 'sn', 'cell1', 'cell2', 'cell3', 'cell4', 'cell5', 'cell6', 'cell7', 'cell8', 'cell9', 'cell10',
-                               'cell11', 'cell12', 'cell13', 'cell14', 'cell15', 'cell16', 'cell17', 'cell18', 'cell19', 'cell20']
-                res.to_sql("consistency_leak_current",con=db_engine, if_exists="append",index=False)
-            logger.info("6060 SN: {} DONE!".format(sn))
-        except:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-
-

+ 0 - 27
LIB/FRONTEND/LeakCurrent/main.py

@@ -1,27 +0,0 @@
-#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')

+ 0 - 2
LIB/FRONTEND/LeakCurrent/run_6060.bat

@@ -1,2 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\LeakCurrent
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\LeakCurrent\deploy_6060.py

+ 0 - 157
LIB/FRONTEND/deltsoc/LFPDeltSoc20210804.py

@@ -1,157 +0,0 @@
-# 获取数据
-from LIB.BACKEND import DBManager
-
-import os
-import pandas as pd
-import numpy as np
-import datetime
-# import matplotlib.pyplot as plt
-#参数初始化
-Capacity = 53.6
-PackFullChrgVolt=69.99
-CellFullChrgVolt=3.6
-CellVoltNums=20
-CellTempNums=4
-FullChrgSoc=98
-PeakSoc=57
-
-#获取数据时间段
-def cal_deltsoc(sn, end_time, start_time):
-    end_time = end_time
-    strat_time = start_time
-    SNnum=str(sn)
-
-    sn = sn
-    st = strat_time
-    et = end_time
-
-
-    dbManager = DBManager.DBManager()
-    df_data = dbManager.get_data(sn=sn, start_time=st, end_time=et, data_groups=['bms'])
-    df_bms = df_data['bms']
-    # 计算电芯Soc差
-    packcrnt = df_bms['总电流[A]']
-    packvolt = df_bms['总电压[V]']
-    SOC = df_bms['SOC[%]']
-    SOH = df_bms['SOH[%]']
-    bmsstat = (df_bms['充电状态']).astype(int)
-    time = pd.to_datetime(df_bms['时间戳'], format='%Y-%m-%d %H:%M:%S')
-
-    # 筛选充电数据
-    ChgStart = []
-    ChgEnd = []
-
-    for i in range(3, len(time) - 3):
-        if i==3 and bmsstat[i]==2 and bmsstat[i+1]==2 and bmsstat[i+2]==2:
-            ChgStart.append(i)
-        elif bmsstat[i-2]!=2 and bmsstat[i-1]!=2 and bmsstat[i]==2:
-            ChgStart.append(i)
-        elif bmsstat[i-1]==2 and bmsstat[i]!=2 and bmsstat[i+1]!=2:
-            ChgEnd.append(i)
-        elif i == (len(time) - 4) and bmsstat[len(bmsstat)-1] == 2 and bmsstat[len(bmsstat)-2] == 2:
-            ChgEnd.append(len(time)-1)
-
-    # 筛选充电起始Soc<46%,电芯温度>15℃的数据
-    if ChgStart:
-        ChgStartValid = []
-        ChgEndValid = []
-
-        for i in range(min(len(ChgStart),len(ChgEnd))):
-            # 获取最小温度值
-            celltemp = []
-            for j in range(1, CellTempNums + 1):
-                s = str(j)
-                temp = df_bms['单体温度' + s]
-                celltemp.append(temp[ChgEnd[i]])
-
-            if SOC[ChgStart[i]] < 46 and SOC[ChgEnd[i]]>80 and min(celltemp) > 10:
-                if ((time[ChgEnd[i]]-time[ChgStart[i]]).total_seconds())/(ChgEnd[i]-ChgStart[i])<30:
-                    ChgStartValid.append(ChgStart[i])
-                    ChgEndValid.append(ChgEnd[i])
-
-    # 计算充电每个单体到达DVDQ峰值的Ah差
-    # 定义滑动平均滤波函数
-    def np_move_avg(a, n, mode="same"):
-        return (np.convolve(a, np.ones((n,)) / n, mode=mode))
-
-
-    # 定义函数:切片Soc>50且Soc<80,并寻找峰值返回峰值点的时间
-    def data_search(t, soc, cellvolt1, packcrnt1):
-        cellvolt2 = np_move_avg(cellvolt1, 5, mode="same")
-        Soc = 0
-        Ah = 0
-        Volt = [cellvolt2[0]]
-        DV_Volt = []
-        DQ_Ah = []
-        DVDQ = []
-        time1 = []
-        soc1 = []
-        soc2 = []
-
-        for m in range(1, len(t)):
-            Step = (t[m] - t[m - 1]).total_seconds()
-            Soc = Soc - packcrnt1[m] * Step * 100 / (3600 * Capacity)
-            Ah = Ah - packcrnt1[m] * Step / 3600
-            if (cellvolt2[m] - Volt[-1]) > 0.9 and Ah>0:
-                DQ_Ah.append(Ah)
-                Volt.append(cellvolt2[m])
-                DV_Volt.append(Volt[-1] - Volt[-2])
-                DVDQ.append((DV_Volt[-1]) / DQ_Ah[-1])
-                Ah = 0
-                time1.append(t[m])
-                soc1.append(Soc)
-                soc2.append(soc[m])
-        df_Data1 = pd.DataFrame({'Time': time1,
-                                'SOC': soc2,
-                                'DVDQ': DVDQ,
-                                'AhSOC': soc1})
-
-        df_Data1 = df_Data1[(df_Data1['SOC'] > 50) & (df_Data1['SOC'] < 75)]
-        # 寻找峰值点,且峰值点个数>3
-        if len(df_Data1['DVDQ'])>2:
-            PeakIndex = df_Data1['DVDQ'].idxmax()
-            df_Data2 = df_Data1[
-                (df_Data1['SOC'] > (df_Data1['SOC'][PeakIndex] - 0.5)) & (df_Data1['SOC'] < (df_Data1['SOC'][PeakIndex] + 0.5))]
-            if len(df_Data2) > 3:
-                return df_Data1['AhSOC'][PeakIndex]
-            else:
-                df_Data1 = df_Data1.drop([PeakIndex])
-                PeakIndex = df_Data1['DVDQ'].idxmax()
-                return df_Data1['AhSOC'][PeakIndex]
-
-
-    # 计算最大最小Soc差
-    if ChgStartValid:
-        DetaSoc2 = []
-        DetaSoc=[]
-        DetaSoc_SN=[]
-        DetaSoc_time=[]
-        for i in range(len(ChgStartValid)):
-            DetaSoc1 = []
-            for j in range(1, CellVoltNums + 1):
-                s = str(j)
-                cellvolt = df_bms['单体电压' + s]
-                cellvolt = list(cellvolt[ChgStartValid[i]:ChgEndValid[i]])
-                Time = list(time[ChgStartValid[i]:ChgEndValid[i]])
-                Packcrnt = list(packcrnt[ChgStartValid[i]:ChgEndValid[i]])
-                SOC1 = list(SOC[ChgStartValid[i]:ChgEndValid[i]])
-                a = data_search(Time, SOC1, cellvolt, Packcrnt)
-                if a:
-                    DetaSoc1.append(a)  # 计算到达峰值点的累计Soc
-            if DetaSoc1:
-                DetaSoc2.append(max(DetaSoc1) - min(DetaSoc1))
-
-        DetaSocMean = np.mean(DetaSoc2)
-        DetaSoc.append(DetaSocMean)
-        DetaSoc_SN.append(SNnum)
-        DetaSoc_time.append(time[ChgStartValid[-1]])
-
-
-        result_DetaSoc={'time':DetaSoc_time,
-                        'SN号':DetaSoc_SN,
-                        'Soc差':DetaSoc}
-        Result_DetaSoc=pd.DataFrame(result_DetaSoc)
-        return Result_DetaSoc
-    return pd.DataFrame()
-
-

+ 0 - 43
LIB/FRONTEND/deltsoc/create_table.py

@@ -1,43 +0,0 @@
-'''
-定义表的结构,并在数据库中创建对应的数据表
-'''
-__author__ = 'lmstack'
-
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy import Column, String, create_engine, Integer, DateTime, BigInteger, FLOAT, TIMESTAMP, func
-from urllib import parse
-Base = declarative_base()
-
-
-class ConsistencyDeltaSoc(Base):
-    __tablename__ = "consistency_delta_soc"
-    __table_args__ = ({'comment': '电池一致性:soc差'})  # 添加索引和表注释
-
-    id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
-    add_time = Column(TIMESTAMP(True), server_default=func.now()) # 创建时间
-    update_time = Column(TIMESTAMP(True), nullable=False, server_default=func.now(), onupdate=func.now()) # 更新时间
-    sn = Column(String(64), comment="sn")
-    time = Column(DateTime, comment="时间")
-    delta_soc = Column(FLOAT, comment="soc差")
-
-
-    # def __init__(self, sn, current, time_stamp, pack_state, line_state):
-    #     self.sn = sn
-    #     self.current = current
-    #     self.time_stamp = time_stamp
-    #     self.pack_state = pack_state
-    #     self.line_state = line_state
-
-# 执行该文件,创建表格到对应的数据库中
-if __name__ == "__main__":
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-    
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    Base.metadata.create_all(db_engine)

+ 0 - 91
LIB/FRONTEND/deltsoc/deploy_6060.py

@@ -1,91 +0,0 @@
-#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.DeltSoc import LFPDeltSoc20210804 as LFPDeltSoc
-from urllib import parse
-import pymysql
-import dateutil.relativedelta
-
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    
-    # 时间设置
-    now_time = datetime.datetime.now()
-    pre_time = now_time + dateutil.relativedelta.relativedelta(weeks=-2)
-    end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 09:00:00")
-    start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 09:00:00")
-    # end_time="2021-08-01 09:00:00"
-    # start_time="2019-01-01 00:00:00"
-    # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei from app_device")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-    
-    
-    # 日志配置
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/6060/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='delta_soc', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-    # SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
-    # SNnums_6060=SNdata_6060['SN号']
-    # # SNnums_6060 = ['PK504B00100004019','PK504B00100004029', 'PK504B00100004080', 'PK504B00100004264', 'PK504B10100004331']
-    # now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
-    # now_time = "2021-08-01 00:00:00" # 定时任务开启时,需要删除改行!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-    # now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
-    # start_time=now_time-datetime.timedelta(days=1000)
-    # end_time=str(now_time)
-    # start_time=str(start_time)
-    for i in range(0, len(df_sn)):
-        try:
-            if df_sn.loc[i, 'imei'][6:9] != '660':
-                continue
-            sn = df_sn.loc[i, 'sn']
-            logger.info("pid-{} 6060 SN: {} START!".format(os.getpid(), sn))
-            res = LFPDeltSoc.cal_deltsoc(sn, end_time, start_time)
-            if not res.empty:
-                res.columns = ['time', 'sn', 'delta_soc']
-                res.to_sql("consistency_delta_soc",con=db_engine, if_exists="append",index=False)
-            logger.info("6060 SN: {} DONE!".format(sn))
-        except:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-
-

+ 0 - 4
LIB/FRONTEND/deltsoc/detaSOC表头及数据类型.xlsx

@@ -1,4 +0,0 @@
-±íÍ·	Ãû³Æ	Êý¾ÝÀàÐÍ
-time	time	timestamps
-SNºÅ	sn	str
-Soc²î	deta_soc	float64

+ 0 - 27
LIB/FRONTEND/deltsoc/main.py

@@ -1,27 +0,0 @@
-#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.DeltSoc import LFPDeltSoc20210804 as LFPDeltSoc
-
-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 = LFPDeltSoc.cal_deltsoc(sn, end_time, start_time)
-        res.to_csv('BMS_DetaSoc_'+sn+'.csv',encoding='GB18030')

+ 0 - 2
LIB/FRONTEND/deltsoc/run_6060.bat

@@ -1,2 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\deltsoc
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\deltsoc\deploy_6060.py

BIN
LIB/FRONTEND/deltsoc/骑享资产梳理-20210621.xlsx


+ 0 - 309
LIB/FRONTEND/soh/LFPSoh 20210711.py

@@ -1,309 +0,0 @@
-# 获取数据
-from LIB.BACKEND import DBManager
-
-import os
-import pandas as pd
-import numpy as np
-import datetime
-# import matplotlib.pyplot as plt
-
-#参数输入
-Capacity = 54
-PackFullChrgVolt=69.99
-CellFullChrgVolt=3.5
-CellVoltNums=20
-CellTempNums=4
-FullChrgSoc=98
-PeakSoc=57
-# #40Ah-OCV
-# LookTab_SOC = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
-# LookTab_OCV = [3.3159, 3.4502, 3.4904, 3.5277, 3.5590, 3.5888, 3.6146, 3.6312, 3.6467, 3.6642, 3.6865, 3.7171, 3.7617,
-#                3.8031, 3.8440, 3.8888, 3.9376, 3.9891, 4.0451, 4.1068, 4.1830]
-#55Ah-OCV
-LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
-LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
-
-#定义滑动滤波函数
-def np_move_avg(a, n, mode="same"):
-    return (np.convolve(a, np.ones((n,)) / n, mode=mode))
-
-#参数初始化
-dvdq_soh=[]
-dvdq_soh_err=[]
-bms_soh=[]
-dvdq_time=[]
-dvdq_sohcfd=[]
-sn_list=[]
-
-#获取数据时间段
-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=30)
-end_time=str(now_time)
-strat_time=str(start_time)
-
-#输入一个含有‘SN号’的xlsx
-SNdata = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
-SNnums=SNdata['SN号']
-for k in range(15):
-    
-    SNnum=str(SNnums[k])
-    sn = SNnum
-    st = '2021-07-06 00:00:00'
-    et = '2021-07-07 20:00:00'
-
-    dbManager = DBManager.DBManager()
-    df_data = dbManager.get_data(sn=sn, start_time=st, end_time=et, data_groups=['bms'])
-    data = df_data['bms']
-
-    packcrnt=data['总电流[A]']
-    packvolt=data['总电压[V]']
-    SOC=data['SOC[%]']
-    SOH=data['SOH[%]']
-    bmsstat=data['充电状态']
-    time= pd.to_datetime(data['时间戳'], format='%Y-%m-%d %H:%M:%S')
-
-    #第一步:筛选充电数据
-    ChgStart=[]
-    ChgEnd=[]
-    for i in range(3, len(time) - 3):
-        if i==3 and bmsstat[i]==2 and bmsstat[i+1]==2 and bmsstat[i+2]==2:
-            ChgStart.append(i)
-        elif bmsstat[i-2]!=2 and bmsstat[i-1]!=2 and bmsstat[i]==2:
-            ChgStart.append(i)
-        elif bmsstat[i-1]==2 and bmsstat[i]!=2 and bmsstat[i+1]!=2:
-            ChgEnd.append(i)
-        elif i == (len(time) - 4) and bmsstat[len(bmsstat)-1] == 2 and bmsstat[len(bmsstat)-2] == 2:
-            ChgEnd.append(len(time)-1)
-
-    #第二步:筛选充电起始Soc<48%,电芯温度>15℃,且满充的数据
-    ChgStartValid1=[]
-    ChgEndValid1=[]
-    ChgStartValid2=[]
-    ChgEndValid2=[]
-
-    for i in range(min(len(ChgStart),len(ChgEnd))):
-
-        #获取最小温度值
-        celltemp = []
-        for j in range(1, CellTempNums+1):
-            s = str(j)
-            temp = data['单体温度' + s]
-            celltemp.append(temp[ChgEnd[i]])
-
-        #寻找最大电压值
-        cellvolt = []
-        for j in range(1, CellVoltNums+1):
-            s = str(j)
-            volt = max(data['单体电压' + s][ChgStart[i]:ChgEnd[i]]/1000)
-            cellvolt.append(volt)
-
-        #筛选满足2点法计算的数据
-        StandingTime=0
-        if max(cellvolt)>CellFullChrgVolt and SOC[ChgStart[i]]<30 and min(celltemp)>5:
-            for k in reversed(range(ChgStart[i])):
-                if abs(packcrnt[k - 2]) < 0.01:
-                    StandingTime = StandingTime + (time[k] - time[k-1]).total_seconds()
-                    if StandingTime > 600:  # 筛选静置时间>10min
-                        ChgStartValid1.append(ChgStart[i])
-                        ChgEndValid1.append(ChgEnd[i])
-                        break
-                else:
-                    break
-
-        #筛选满足DV/DQ方法的数据
-        if max(cellvolt)>CellFullChrgVolt and SOC[ChgStart[i]]<45 and min(celltemp)>5:
-            if ((time[ChgEnd[i]]-time[ChgStart[i]]).total_seconds())/(ChgEnd[i]-ChgStart[i])<60:
-                ChgStartValid2.append(ChgStart[i])
-                ChgEndValid2.append(ChgEnd[i])
-
-    #第三步:计算充电Soc和Soh
-
-    # 两点法计算soh
-    Soc=[]
-    Time=[]
-    Soc_Err=[]
-    Bms_Soc=[]
-
-    Soh1=[]
-    Time1=[]
-    Bms_Soh1=[]
-    Soh_Err1=[]
-
-    for i in range(len(ChgStartValid1)):
-
-        #寻找最大电压值
-        cellvolt = []
-        for j in range(1, CellVoltNums+1):
-            s = str(j)
-            volt = max(data['单体电压' + s])
-            cellvolt.append(volt)
-        voltmax_index = cellvolt.index(max(cellvolt)) + 1
-        cellvolt = data['单体电压' + str(voltmax_index)] / 1000
-
-        #soc
-        Soc.append(np.interp(cellvolt[ChgStartValid1[i]-3],LookTab_OCV,LookTab_SOC))
-        Time.append(time[ChgStartValid1[i]-3])
-        Bms_Soc.append(SOC[ChgStartValid1[i]-3])
-        Soc_Err.append(Bms_Soc[-1]-Soc[-1])
-
-        #soh
-        Ocv_Soc=np.interp(cellvolt[ChgStartValid1[i]-3],LookTab_OCV,LookTab_SOC)
-        Ah=0
-
-        for j in range(ChgStartValid1[i],ChgEndValid1[i]):
-            #计算soc
-            Step=(time[j]-time[j-1]).total_seconds()
-            Time.append(time[j])
-            Bms_Soc.append(SOC[j])
-            if Soc[-1]-(packcrnt[j]*Step*100)/(3600*Capacity)<100:
-                Soc.append(Soc[-1]-(packcrnt[j]*Step*100)/(3600*Capacity))
-            else:
-                Soc.append(100)
-            Soc_Err.append(Bms_Soc[-1] - Soc[-1])
-
-            #两点法计算soh
-            Ah=Ah-packcrnt[j]*Step/3600
-        Soh1.append(Ah*100/((FullChrgSoc-Ocv_Soc)*0.01*Capacity))
-        Bms_Soh1.append(SOH[i])
-        Soh_Err1.append(Bms_Soh1[-1]-Soh1[-1])
-        Time1.append(time[ChgStartValid1[i]])
-
-    # DV/DQ法计算soh
-    Soh2=[]
-    Time2=[]
-    Bms_Soh2=[]
-    Soh_Err2=[]
-    SohCfd = []
-    sn_list=[]
-
-    for i in range(len(ChgStartValid2)):
-
-        #寻找最大电压值
-        cellvolt1 = []
-        cellvolt=[]
-        for j in range(1, CellVoltNums+1):
-            s = str(j)
-            volt = data['单体电压' + s]
-            cellvolt1.append(volt[ChgEndValid2[i]])
-        voltmax1_index = cellvolt1.index(max(cellvolt1)) + 1
-        cellvolt1 = data['单体电压' + str(voltmax1_index)] / 1000
-
-        #电压采用滑动平均滤波
-        cellvolt=np_move_avg(cellvolt1, 3, mode="same")
-
-
-        #参数赋初始值
-        Ah = 0
-        Volt = cellvolt[ChgStartValid2[i]]
-        DV_Volt=[]
-        DQ_Ah = []
-        DVDQ = []
-        time2 = []
-        soc2 = []
-        Ah_tatal=[0]
-        xvolt=[]
-        #计算DV和DQ值
-        for j in range(ChgStartValid2[i],ChgEndValid2[i]):
-            Step=(time[j+1]-time[j]).total_seconds()
-            Ah=Ah-packcrnt[j]*Step/3600
-            if (cellvolt[j]-Volt)>0.0009 and Ah>0:
-                Ah_tatal.append(Ah_tatal[-1]+Ah)
-                DQ_Ah.append(Ah)
-                DV_Volt.append(cellvolt[j]-Volt)
-                DVDQ.append((DV_Volt[-1])/DQ_Ah[-1])
-                xvolt.append(cellvolt[j])
-                Volt=cellvolt[j]
-                Ah = 0
-                time2.append(time[j])
-                soc2.append(SOC[j])
-
-        #切片Soc>50且Soc<80
-        Data1 = pd.DataFrame({'SOC': soc2,
-                                'DVDQ': DVDQ,
-                                'Ah_tatal': Ah_tatal[:-1],
-                                'DQ_Ah':DQ_Ah,
-                                'DV_Volt':DV_Volt,
-                                'XVOLT':xvolt})
-
-        Data1=Data1[(Data1['SOC']>50) & (Data1['SOC']<80)]
-
-        #寻找峰值并计算Soh和置信度
-        # 获取最小温度值
-        celltemp = []
-        for j in range(1, CellTempNums+1):
-            s = str(j)
-            temp = data['单体温度' + s]
-            celltemp.append(temp[ChgStartValid2[i]])
-        if len(Data1['DVDQ'])>1:
-            PeakIndex=Data1['DVDQ'].idxmax()
-            #筛选峰值点附近±0.5%SOC内的数据
-            Data2=Data1[(Data1['SOC']>(Data1['SOC'][PeakIndex]-0.5)) & (Data1['SOC']<(Data1['SOC'][PeakIndex]+0.5))]
-            if len(Data2)>2:
-                Ah_tatal1 = Data1['Ah_tatal']
-                DVDQ = Data1['DVDQ']
-                soc2 = Data1['SOC']
-                xvolt = Data1['XVOLT']
-                if soc2[PeakIndex]>50 and soc2[PeakIndex]<80:
-                    DVDQ_SOH=(Ah_tatal[-1]-Ah_tatal1[PeakIndex]) * 100 / ((FullChrgSoc - PeakSoc) * 0.01 * Capacity)
-                    if DVDQ_SOH<95:
-                        DVDQ_SOH=DVDQ_SOH*0.3926+58.14
-                    if DVDQ_SOH>70 and DVDQ_SOH<120:
-                        Soh2.append(DVDQ_SOH)
-                        Bms_Soh2.append(SOH[ChgStartValid2[i]])
-                        Soh_Err2.append(Bms_Soh2[-1] - Soh2[-1])
-                        Time2.append(time[ChgStartValid2[i]])
-                        sn_list.append(SNnum)
-
-                        #计算置信度
-                        if min(celltemp)<10:
-                            SohCfd.append(50)
-                        elif min(celltemp)<20:
-                            SohCfd.append(80)
-                        else:
-                            SohCfd.append(100)
-            else:
-                Data1=Data1.drop([PeakIndex])
-                PeakIndex = Data1['DVDQ'].idxmax()
-                Data2 = Data1[(Data1['SOC'] > (Data1['SOC'][PeakIndex] - 0.5)) & (Data1['SOC'] < (Data1['SOC'][PeakIndex] + 0.5))]
-                if len(Data2) > 3:
-                    Ah_tatal1 = Data1['Ah_tatal']
-                    DVDQ = Data1['DVDQ']
-                    soc2 = Data1['SOC']
-                    xvolt = Data1['XVOLT']
-                    if soc2[PeakIndex]>50 and soc2[PeakIndex]<80:
-                        DVDQ_SOH=(Ah_tatal[-1]-Ah_tatal1[PeakIndex]) * 100 / ((FullChrgSoc - PeakSoc) * 0.01 * Capacity)
-                        if DVDQ_SOH<95:
-                            DVDQ_SOH=DVDQ_SOH*0.3926+58.14
-                        if DVDQ_SOH>70 and DVDQ_SOH<120:
-                            Soh2.append(DVDQ_SOH)
-                            Bms_Soh2.append(SOH[ChgStartValid2[i]])
-                            Soh_Err2.append(Bms_Soh2[-1] - Soh2[-1])
-                            Time2.append(time[ChgStartValid2[i]])
-                            sn_list.append(SNnum)
-
-                            #计算置信度
-                            if min(celltemp)<10:
-                                SohCfd.append(50)
-                            elif min(celltemp)<20:
-                                SohCfd.append(80)
-                            else:
-                                SohCfd.append(100)
-
-    #处理数据
-    if len(Soh2)>5:
-        Soh2=np_move_avg(Soh2,5,mode="valid")
-        result_soh2={'时间': Time2[4::],
-            'SN号':sn_list[4::],
-            'BMS_SOH': Bms_Soh2[4::],
-            'SOH': Soh2,
-            'SOH误差': Soh_Err2[4::]}
-    else:
-        result_soh2={'时间': Time2,
-            'SN号':sn_list,
-            'BMS_SOH': Bms_Soh2,
-            'SOH': Soh2,
-            'SOH误差': Soh_Err2}
-    #第四步:将数据存入Excel
-    Result_Soh2=pd.DataFrame(result_soh2)
-    Result_Soh2.to_csv('BMS_SOH_'+SNnum+'.csv',encoding='GB18030')

+ 0 - 173
LIB/FRONTEND/soh/NCMSoh 20210716.py

@@ -1,173 +0,0 @@
-# 获取数据
-from LIB.BACKEND import DBManager
-
-import os
-import pandas as pd
-import numpy as np
-import datetime
-# import matplotlib.pyplot as plt
-
-#参数输入
-Capacity = 41
-PackFullChrgVolt=69.99
-CellFullChrgVolt=3.5
-CellVoltNums=17
-CellTempNums=4
-FullChrgSoc=98
-PeakSoc=57
-# #40Ah-OCV
-LookTab_SOC = [0,	3.534883489,	8.358178409,	13.18141871,	18.00471528,	22.82796155,	27.65123833,	32.47444668,	37.29772717,	42.12099502,	46.94423182,	51.76744813,	56.59070685,	61.4139927,	66.23719857,	71.0604667,	75.88373853,	80.70702266,	85.5302705,	90.35352009,	95.17676458,	100]
-LookTab_OCV = [3.3159,	3.4384,	3.4774,	3.5156,	3.5478,	3.5748,	3.6058,	3.6238,	3.638,	3.6535,	3.6715,	3.6951,	3.7279,	3.7757,	3.8126,	3.8529,	3.8969,	3.9446,	3.9946,	4.0491,	4.109,	4.183]
-# #55Ah-OCV
-# LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
-# LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
-
-#参数初始化
-Soh3=[]
-Time3=[]
-Bms_Soh3=[]
-Soh_Err3=[]
-sn_list=[]
-
-#获取数据时间段
-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)
-strat_time=str(start_time)
-
-#输入一个含有‘SN号’的xlsx
-SNdata = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6040骑享')
-SNnums=SNdata['SN号']
-for k in range(len(SNnums)):
-    SNnum=str(SNnums[k])
-
-    sn = SNnum
-    st = strat_time
-    et = end_time
-
-    dbManager = DBManager.DBManager()
-    df_data = dbManager.get_data(sn=sn, start_time=st, end_time=et, data_groups=['bms'])
-    data = df_data['bms']
-    # print(data)
-
-    packcrnt=data['总电流[A]']
-    packvolt=data['总电压[V]']
-    SOC=data['SOC[%]']
-    SOH=data['SOH[%]']
-    bmsstat=data['充电状态']
-    time= pd.to_datetime(data['时间戳'], format='%Y-%m-%d %H:%M:%S')
-
-    #第一步:筛选充电数据
-    if len(packcrnt)>100:
-        ChgStart=[]
-        ChgEnd=[]
-        for i in range(3, len(time) - 3):
-            if i==3 and bmsstat[i]==2 and bmsstat[i+1]==2 and bmsstat[i+2]==2:
-                ChgStart.append(i)
-            elif bmsstat[i-2]!=2 and bmsstat[i-1]!=2 and bmsstat[i]==2:
-                ChgStart.append(i)
-            elif bmsstat[i-1]==2 and bmsstat[i]!=2 and bmsstat[i+1]!=2:
-                ChgEnd.append(i-1)
-            elif i == (len(time) - 4) and bmsstat[len(bmsstat)-1] == 2 and bmsstat[len(bmsstat)-2] == 2:
-                ChgEnd.append(len(time)-2)
-
-        #第二步:筛选充电起始Soc<45% & SOC>85%,电芯温度>5℃
-        ChgStartValid1=[]
-        ChgEndValid1=[]
-        ChgStartValid2=[]
-        ChgEndValid2=[]
-        StandingNum=[]
-
-        for i in range(min(len(ChgStart),len(ChgEnd))):
-
-            #获取最小温度值
-            celltemp = []
-            for j in range(1, CellTempNums+1):
-                s = str(j)
-                temp = data['单体温度' + s]
-                celltemp.append(temp[ChgEnd[i]])
-            
-            #去除电流0点   
-            for k in range(ChgStart[i],ChgEnd[i]):
-                if packcrnt[k]<-0.5 and packcrnt[k+1]>-0.5 and packcrnt[k+2]>-0.5 and packcrnt[k+3]>-0.5:
-                    ChgEnd[i]=k
-            
-            #计算最大packvolt
-            if len(packvolt[ChgStart[i]:ChgEnd[i]])>0:
-                packvoltMAX=max(packvolt[ChgStart[i]:ChgEnd[i]])
-
-                #筛选满足2点法计算的数据
-                StandingTime=0
-                StandingTime1=0
-                StandingTime2=0
-                if SOC[ChgEnd[i]]>85 and SOC[ChgStart[i]]<45 and min(celltemp)>5:
-                    for m in range(min(len(packcrnt)-ChgEnd[i]-2,ChgStart[i]-2)):
-                        if abs(packcrnt[ChgStart[i] - m - 1]) < 0.1:
-                            StandingTime = StandingTime + (time[ChgStart[i] - m] - time[ChgStart[i] - m - 1]).total_seconds()
-                        if abs(packcrnt[ChgEnd[i] + m + 1]) < 0.1:
-                            StandingTime1 = StandingTime1 + (time[ChgEnd[i] + m + 1] - time[ChgEnd[i] + m]).total_seconds()
-                        if StandingTime > 900 and StandingTime1>900 and ((time[ChgEnd[i]]-time[ChgStart[i]]).total_seconds())/(ChgEnd[i]-ChgStart[i])<60:  #筛选静置时间>15min且慢充过程丢失数据少
-                            ChgStartValid1.append(ChgStart[i])
-                            ChgEndValid1.append(ChgEnd[i])
-                            StandingNum.append(m)
-                            break
-                        if abs(packcrnt[ChgStart[i] - m - 2])>0.5 and abs(packcrnt[ChgEnd[i] + m + 2])>0.5:
-                            break
-
-        # 计算soh
-        Soh1=[]
-        Soh2=[]
-        Time1=[]
-        Bms_Soh1=[]
-        Soh_Err1=[]
-        sn_list1=[]
-        #两点法计算Soh
-        if len(ChgStartValid1)>0:
-            for i in range(len(ChgStartValid1)):
-                #计算Ah
-                Ah=0
-                for j in range(ChgStartValid1[i],ChgEndValid1[i]):
-                    Step=(time[j+1]-time[j]).total_seconds()
-                    Ah=Ah-packcrnt[j+1]*Step/3600
-                #计算每个电芯的Soh
-                for j in range(1, CellVoltNums+1):
-                    s = str(j)
-                    cellvolt = data['单体电压' + s]/1000
-                    OCVStart=cellvolt[ChgStartValid1[i]-2]
-                    OCVEnd=cellvolt[ChgEndValid1[i]+StandingNum[i]]
-                    #soh
-                    Ocv_Soc1=np.interp(OCVStart,LookTab_OCV,LookTab_SOC)
-                    Ocv_Soc2=np.interp(OCVEnd,LookTab_OCV,LookTab_SOC)
-                    Soh2.append(Ah*100/((Ocv_Soc2-Ocv_Soc1)*0.01*Capacity))
-                Soh1.append(np.mean(Soh2))
-                Bms_Soh1.append(SOH[ChgStartValid1[i]])
-                Soh_Err1.append(Bms_Soh1[-1]-Soh1[-1])
-                Time1.append(time[ChgStartValid1[i]])
-                sn_list1.append(SNnum)
-       
-            # Soh3.append(np.mean(Soh1))
-            # Bms_Soh3.append(np.mean(Bms_Soh1))
-            # Soh_Err3.append(np.mean(Soh_Err1))
-            # Time3.append(time[ChgStartValid1[-1]])
-            # sn_list.append(SNnum)
-
-        #第四步:将数据存入Excel
-            result_soh2={'时间': Time1,
-                'SN号': sn_list1,
-                'BMS_SOH': Bms_Soh1,
-                'SOH': Soh1,
-                'SOH误差': Soh_Err1}
-
-            Result_Soh2=pd.DataFrame(result_soh2)
-            Result_Soh2.to_csv('BMS_SOH_'+SNnum+'.csv',encoding='GB18030')
-
-#     result_soh1={'时间': Time3,
-#         'SN号':sn_list,
-#         'BMS_SOH': Bms_Soh3,
-#         'SOH': Soh3,
-#         'SOH误差': Soh_Err3}
-
-# Result_Soh1=pd.DataFrame(result_soh1)
-# print(Result_Soh1)
-# Result_Soh1.to_csv('BMS_SOH_'+'6040'+'.csv',encoding='GB18030')

+ 0 - 91
LIB/FRONTEND/soh/deploy_4840.py

@@ -1,91 +0,0 @@
-
-__author__ = 'lmstack'
-#coding=utf-8
-import os
-import datetime
-import pandas as pd
-from LIB.BACKEND import DBManager, Log
-from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-import time, datetime
-import dateutil.relativedelta
-import traceback
-from LIB.MIDDLE.soh import NCMSoh_4840 as NCMSoh
-from urllib import parse
-import pymysql
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    
-    # 时间设置
-    now_time = datetime.datetime.now()
-    pre_time = now_time + dateutil.relativedelta.relativedelta(months=-1)#上个月时间
-    end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 01:00:00")
-    start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 01:00:00")
-    
-    # end_time="2021-08-02 01:00:00"
-    # start_time="2019-01-01 00:00:00"
-    
-
-    # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei from app_device")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-    
-    # 日志配置
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/4840/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='soh', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-
-    # SNdata_4840 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='4840骑享')
-    # SNnums_4840=SNdata_4840['SN号']
-
-
-    for i in range(0, len(df_sn)):
-        try:
-            if df_sn.loc[i, 'imei'][6:9] != '440':
-                continue
-            sn = df_sn.loc[i, 'sn']
-            
-            # if sn in SNnums_4840.tolist():
-            #     print(sn)
-            #     continue
-            logger.info("pid-{} 4840 SN: {} START!".format(os.getpid(), sn))
-            res = NCMSoh.cal_soh(sn, end_time, start_time)
-            if not res.empty:
-                res.columns = ['time', 'sn', 'bms_soh', 'soh', 'soh_err']
-                res.to_sql("soh_result",con=db_engine, if_exists="append",index=False)
-            logger.info("4840 SN: {} DONE!".format(sn))
-        except:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-

+ 0 - 92
LIB/FRONTEND/soh/deploy_6040.py

@@ -1,92 +0,0 @@
-
-__author__ = 'lmstack'
-#coding=utf-8
-import os
-import datetime
-import pandas as pd
-from LIB.BACKEND import DBManager, Log
-from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-import time, datetime
-import dateutil.relativedelta
-import traceback
-from LIB.MIDDLE.soh import NCMSoh_20210716 as NCMSoh
-from urllib import parse
-import pymysql
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    
-    # 时间设置
-    now_time = datetime.datetime.now()
-    pre_time = now_time + dateutil.relativedelta.relativedelta(months=-1)#上个月时间
-    end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 01:00:00")
-    start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 01:00:00")
-    # end_time="2021-08-03 01:00:00"
-    # start_time="2019-01-01 00:00:00"
-    
-    # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei from app_device")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-    
-    # 日志配置
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/6040/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='soh', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-    # SNdata_6040 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6040骑享')
-    # SNnums_6040=SNdata_6040['SN号']
-    # now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
-    # now_time = "2021-08-01 00:00:00" # 定时任务开启时,需要删除改行!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    # now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
-    # start_time=now_time-datetime.timedelta(days=1000)
-    # end_time=str(now_time)
-    # start_time=str(start_time)
-
-    for i in range(0, len(df_sn)):
-        try:
-            if df_sn.loc[i, 'imei'][6:9] != '640':
-                continue
-            sn = df_sn.loc[i, 'sn']
-            # if sn in SNnums_6040.tolist():
-            #     print(sn)
-            #     continue
-            logger.info("pid-{} 6040 SN: {} START!".format(os.getpid(), sn))
-            res = NCMSoh.cal_soh(sn, end_time, start_time)
-            if not res.empty:
-                res.columns = ['time', 'sn', 'bms_soh', 'soh', 'soh_err']
-                res.to_sql("soh_result",con=db_engine, if_exists="append",index=False)
-            logger.info("6040 SN: {} DONE!".format(sn))
-        except:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-

+ 0 - 97
LIB/FRONTEND/soh/deploy_6060.py

@@ -1,97 +0,0 @@
-
-__author__ = 'lmstack'
-#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 dateutil.relativedelta
-import traceback
-from LIB.MIDDLE.soh import NCMSoh_20210716 as NCMSoh
-from LIB.MIDDLE.soh import LFPSoh_20210711 as LFPSoh
-from urllib import parse
-import pymysql
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    
-    # 时间设置
-    now_time = datetime.datetime.now()
-    pre_time = now_time + dateutil.relativedelta.relativedelta(months=-1)#上个月时间
-    end_time=datetime.datetime.strftime(now_time,"%Y-%m-%d 01:00:00")
-    start_time=datetime.datetime.strftime(pre_time,"%Y-%m-%d 01:00:00")
-    # end_time="2021-08-01 01:00:00"
-    # start_time="2019-01-01 00:00:00"
-    
-    # 更新sn列表
-    host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
-    port=3306
-    db='qixiang_oss'
-    user='qixiang_oss'
-    password='Qixiang2021'
-    conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
-    cursor = conn.cursor()
-    cursor.execute("select sn, imei from app_device")
-    res = cursor.fetchall()
-    df_sn = pd.DataFrame(res, columns=['sn', 'imei'])
-    df_sn = df_sn.reset_index(drop=True)
-    conn.close();
-    
-    # 数据库配置
-    host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
-    port = 3306
-    user = 'qx_cas'
-    password = parse.quote_plus('Qx@123456')
-    database = 'qx_cas'
-
-    db_engine = create_engine(
-        "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
-            user, password, host, port, database
-        ))
-    DbSession = sessionmaker(bind=db_engine)
-     
-    # 日志配置
-    
-    now_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()).replace(":","_")
-    log_path = 'log/6060/' + now_str
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
-    log = Log.Mylog(log_name='soh', log_level = 'info')
-    log.set_file_hl(file_name='{}/info.log'.format(log_path), log_level='info', size=1024* 1024 * 100)
-    log.set_file_hl(file_name='{}/error.log'.format(log_path), log_level='error', size=1024* 1024 * 100)
-    logger = log.get_logger()
-
-    logger.info("pid is {}".format(os.getpid()))
-    
-
-
-    # SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
-    # SNdata_6060=SNdata_6060['SN号']
-    # now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
-    # now_time = "2021-08-01 00:00:00" # 定时任务开启时,需要删除改行!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    # now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
-    # start_time=now_time-datetime.timedelta(days=1000)
-    # end_time=str(now_time)
-    # start_time=str(start_time)
-
-    for i in range(0, len(df_sn)):
-        try:
-            if df_sn.loc[i, 'imei'][6:9] != '660':
-                continue
-            sn = df_sn.loc[i, 'sn']
-            # if sn in SNdata_6060.tolist():
-            #     print(sn)
-            #     continue
-            logger.info("pid-{} 6060 SN: {} START!".format(os.getpid(), sn))
-            res = LFPSoh.cal_soh(sn, end_time, start_time)
-            if not res.empty:
-                res.columns = ['time', 'sn', 'bms_soh', 'soh', 'soh_err']
-                res.to_sql("soh_result",con=db_engine, if_exists="append",index=False)
-            logger.info("6060 SN: {} DONE!".format(sn))
-        except:
-            logger.error(traceback.format_exc)
-            logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
-

+ 0 - 34
LIB/FRONTEND/soh/main.py

@@ -1,34 +0,0 @@
-#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.soh import NCMSoh_20210716 as NCMSoh
-from LIB.MIDDLE.soh import LFPSoh_20210711 as LFPSoh
-
-from urllib import parse
-
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    SNdata_6040 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6040骑享')
-    SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
-    SNnums_6060=SNdata_6060['SN号']
-    SNnums_6040=SNdata_6040['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_6040.tolist():
-        res = NCMSoh.cal_soh(sn, end_time, start_time)
-        res.to_csv('BMS_SOH_'+sn+'.csv',encoding='GB18030')
-    
-    for sn in SNnums_6060.tolist():
-        res = LFPSoh.cal_soh(sn, end_time, start_time)
-        res.to_csv('BMS_SOH_'+sn+'.csv',encoding='GB18030')

+ 0 - 2
LIB/FRONTEND/soh/run_4840.bat

@@ -1,2 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\soh
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\soh\deploy_4840.py

+ 0 - 2
LIB/FRONTEND/soh/run_6040.bat

@@ -1,2 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\soh
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\soh\deploy_6040.py

+ 0 - 2
LIB/FRONTEND/soh/run_6060.bat

@@ -1,2 +0,0 @@
-cd /d D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\soh
-D:\env\py_pro\python.exe D:\deploy\python_platform\data_analyze_platform\LIB\FRONTEND\soh\deploy_6060.py

+ 0 - 6
LIB/FRONTEND/soh/soh表头及数据类型.xlsx

@@ -1,6 +0,0 @@
-表头	名称	数据类型
-时间	time	timestamps
-SN号	sn	str
-BMS_SOH	bms_soh	float64
-SOH	soh	float64
-SOH误差	soh_err	float64

BIN
LIB/FRONTEND/soh/骑享资产梳理-20210621.xlsx