lmstack 3 years ago
parent
commit
3328e1fd86

+ 15 - 8
LIB/FRONTEND/CellStateEstimation/BatSafetyAlarm/deploy.py

@@ -25,7 +25,10 @@ def diag_cal(df_sn, df_bms_ram, log_name):
     
     # 日志
     logger = logging.getLogger()
-    fh = logging.FileHandler(log_name + ".log", encoding="utf-8",mode="a")
+    
+    fh = logging.handlers.RotatingFileHandler(log_name + ".log", encoding="utf-8",maxBytes=1024*1024*1024, backupCount=5, mode="a")
+    # fh = logging.handlers.db_res_engine(log_name + ".log", encoding="utf-8",maxBytes=1024*1024*1024, backupCount=5, mode="a")
+
     formatter = logging.Formatter("%(asctime)s - %(name)s-%(levelname)s %(message)s")
     fh.setFormatter(formatter)
     logger.addHandler(fh)
@@ -47,7 +50,7 @@ def diag_cal(df_sn, df_bms_ram, log_name):
     conn = pymysql.connect(host=host2, port=port2, user=user2, password=password2, database=db2)
     cursor = conn.cursor()
     
-    result=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice from all_fault_info where factory = '{}'".format('骑享'), db_res_engine)
+    result=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice from all_fault_info", db_res_engine)
     result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
     df_diag_ram=result[(result['end_time']=='0000-00-00 00:00:00') & (result['code']==119)]
     df_bms_ram=pd.DataFrame(columns=['time', 'sn', 'packvolt', 'cellvolt', 'celltemp'])
@@ -58,7 +61,9 @@ def diag_cal(df_sn, df_bms_ram, log_name):
     start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
     end_time=now_time.strftime('%Y-%m-%d %H:%M:%S')
 
+
     for i in range(0, len(df_sn)):
+        factory = "骑享"
         try:
             if df_sn.loc[i, 'imei'][5:9] == 'N640':
                 celltype=1 #6040三元电芯
@@ -70,11 +75,13 @@ def diag_cal(df_sn, df_bms_ram, log_name):
                 celltype=3 #力信 50ah三元电芯
             elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
                 celltype=4 #CATL 50ah三元电芯
+            elif df_sn.loc[i, 'imei'][3:9] == 'CLL128':    
+                celltype=100 # 重卡
+                factory = "金茂换电"
             else:
                 logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
                 continue
             sn = df_sn.loc[i, 'sn']
-            
             logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
 
             #读取原始数据库数据........................................................................................................................................................
@@ -106,9 +113,8 @@ def diag_cal(df_sn, df_bms_ram, log_name):
                     if not df_diag_res.empty:
                         df_diag_res.columns = ['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']
                         df_diag_res['add_time'] = datetime.datetime.now()
-                        df_diag_res['factory'] = '骑享'
-                        df_diag_res.to_sql("all_fault_info",con=conn, if_exists="append",index=False)
-                        conn.commit()
+                        df_diag_res['factory'] = factory
+                        df_diag_res.to_sql("all_fault_info",con=db_res_engine, if_exists="append",index=False)
                         logger.info(u"{} 写入成功!!!\n".format(sn), exc_info=True)
                 
             #当前热失控已超过三天变为历史故障并写入数据库,并删除原有数据库中的当前故障和ram中的当前故障
@@ -121,7 +127,7 @@ def diag_cal(df_sn, df_bms_ram, log_name):
                     try:
 
                         cursor.execute('''
-                                    update all_fault_info set update_time='{}',end_time='{}', Batpos={} where product_id='{}' and end_time='0000-00-00 00:00:00' and code={} and factory='骑享'
+                                    update all_fault_info set update_time='{}',end_time='{}', Batpos={} where product_id='{}' and end_time='0000-00-00 00:00:00' and code={}
                                     '''.format(datetime.datetime.now(), end_time, 1,sn, 119))
                         conn.commit()
                         logger.info(u"{} 更新成功\n".format(sn), exc_info=True)
@@ -151,7 +157,7 @@ def mainprocess():
     password='Qixiang2021'
     conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
     cursor = conn.cursor()
-    cursor.execute("select sn, imei, add_time from app_device")
+    cursor.execute("select sn, imei, add_time from app_device where status in (1,2,3)")
     res = cursor.fetchall()
     df_sn = pd.DataFrame(res, columns=['sn', 'imei', 'add_time'])
     df_sn = df_sn.reset_index(drop=True)
@@ -243,6 +249,7 @@ if __name__ == "__main__":
     # result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
     # df_diag_ram=result[(result['end_time']=='0000-00-00 00:00:00') & (result['code']==119)]
     df_bms_ram=pd.DataFrame(columns=['time', 'sn', 'packvolt', 'cellvolt', 'celltemp'])
+    mainprocess()
     #定时任务.......................................................................................................................................................................
     scheduler = BlockingScheduler()
     scheduler.add_job(mainprocess, 'interval', seconds=60, id='diag_job')

+ 21 - 20
LIB/FRONTEND/CellStateEstimation/BatSafetyWarning/deploy.py

@@ -60,15 +60,15 @@ def saftywarning_cal():
     conn_cas = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
     cursor_cas = conn_cas.cursor()
     
-    result=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice from all_fault_info where factory = '{}'".format('骑享'), db_safety_platform_engine)
+    result=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice from all_fault_info", db_safety_platform_engine)
     result = result[['start_time', 'end_time', 'product_id', 'code', 'level', 'info', 'advice']]
     df_fault_ram=result[(result['end_time']=='0000-00-00 00:00:00') & (result['code']==110)]
     
     now_time=datetime.datetime.now()
-    start_time=now_time-datetime.timedelta(hours=12)
+    start_time=now_time-datetime.timedelta(hours=6)
     start_time1=now_time-datetime.timedelta(days=7)
-    start_time2=now_time-datetime.timedelta(days=90)
-    start_time3=now_time-datetime.timedelta(days=3)
+    start_time2=now_time-datetime.timedelta(days=3)
+    start_time3=now_time-datetime.timedelta(days=1)
 
     start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
     start_time1=start_time1.strftime('%Y-%m-%d %H:%M:%S')
@@ -77,6 +77,7 @@ def saftywarning_cal():
     end_time=now_time.strftime('%Y-%m-%d %H:%M:%S')
 
     for i in range(0, len(df_sn)):
+        factory = "骑享"
         try:
             if df_sn.loc[i, 'imei'][5:9] == 'N640':
                 celltype=1 #6040三元电芯
@@ -86,8 +87,9 @@ def saftywarning_cal():
                 celltype=99 # 6060锂电芯
             elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
                 celltype=3 #力信 50ah三元电芯
-            elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
-                celltype=4 #CATL 50ah三元电芯
+            elif df_sn.loc[i, 'imei'][3:9] == 'CLL128':    
+                celltype=100 # 重卡
+                factory = "金茂换电"
             else:
                 logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
                 continue
@@ -97,7 +99,7 @@ def saftywarning_cal():
 
             # 读取soh数据
             df_soh = pd.read_sql("select time_st,sn,soh,cellsoh from cellstateestimation_soh where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
-            df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num from cellstateestimation_uniform_socvoltdiff where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
+            df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank from cellstateestimation_uniform_socvoltdiff where sn = '{}' order by id desc limit 1".format(sn), db_qxcas_engine)
             df_uniform.loc[0,'cellvolt_rank']=str([1]*20)
             df_voltsigma=pd.DataFrame()
             #读取原始数据库数据................................................................................id........................................................................
@@ -147,10 +149,9 @@ def saftywarning_cal():
                     df_rank_res.to_sql("cellstateestimation_uniform_socvoltdiff",con=db_qxcas_engine, if_exists="append",index=False)
                 
                 #电压离群.....................................................................................................................................................
-                OutLineVol=VoltStray.main(sn,df_bms,celltype)
-                if not OutLineVol.empty:
-                    df_voltsigma=OutLineVol
-                    OutLineVol.to_sql("outlier_voltchangeratio",con=db_qxcas_engine, if_exists="append",index=False)
+                df_voltsigma=VoltStray.main(sn,df_bms,celltype)
+                if not df_voltsigma.empty:
+                    df_voltsigma.to_sql("outlier_voltchangeratio",con=db_qxcas_engine, if_exists="append",index=False)
 
 
                 #内短路ram处理.........................................................
@@ -173,8 +174,8 @@ def saftywarning_cal():
             #电池热安全预警..............................................................................................................................................................
             #读取内短路、析锂和一致性结果数据库数据
             df_short = pd.read_sql("select time_sp,sn,short_current from cellstateestimation_intershort where sn = '{}' and time_sp between '{}' and '{}'".format(sn,start_time1,end_time), db_qxcas_engine)
-            df_liplated = pd.read_sql("select time,sn,liplated,liplated_amount from mechanism_liplated where sn = '{}' and time between '{}' and '{}'".format(sn,start_time2,end_time), db_qxcas_engine)
-            df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank from cellstateestimation_uniform_socvoltdiff where sn = '{}' and time between '{}' and '{}'".format(sn,start_time3,end_time), db_qxcas_engine)
+            # df_liplated = pd.read_sql("select time,sn,liplated,liplated_amount from mechanism_liplated where sn = '{}' and time between '{}' and '{}'".format(sn,start_time2,end_time), db_qxcas_engine)
+            df_uniform = pd.read_sql("select time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank from cellstateestimation_uniform_socvoltdiff where sn = '{}' and time between '{}' and '{}'".format(sn,start_time2,end_time), db_qxcas_engine)
             df_voltsigma = pd.read_sql("select time,sn,VolOl_Uni,VolChng_Uni from outlier_voltchangeratio where sn = '{}' and time between '{}' and '{}'".format(sn,start_time3,end_time), db_qxcas_engine)
 
             #获取sn的故障RAM
@@ -182,12 +183,12 @@ def saftywarning_cal():
             
             #热安全预警
             if df_fault_ram_sn.empty:
-                BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_liplated,df_uniform,df_voltsigma)
+                BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_uniform,df_voltsigma,df_soh)
                 df_warning_res=BatWarning.diag()
                 #当前热失控故障写入数据库
                 if not df_warning_res.empty:
                     df_warning_res['add_time'] = datetime.datetime.now()
-                    df_warning_res['factory'] = '骑享'
+                    df_warning_res['factory'] = factory
                     df_warning_res.to_sql("all_fault_info",con=db_safety_platform_engine, if_exists="append",index=False)
                     conn_platform.commit()
             else:
@@ -196,9 +197,9 @@ def saftywarning_cal():
                     df_fault_ram_sn['end_time']=end_time
                     df_fault_ram_sn['Batpos']=1
                     try:
-                        cursor.execute('''
-                                update all_fault_info set update_time='{}',end_time='{}', Batpos={} where product_id='{}' and code={} and end_time='0000-00-00 00:00:00' and factory='骑享'
-                                '''.format(datetime.datetime.now(), df_fault_ram_sn.loc[0,'end_time'], df_fault_ram_sn.loc[0,'Batpos'],sn, 110))
+                        cursor_platform.execute('''
+                                update all_fault_info set update_time='{}',end_time='{}', Batpos={} where product_id='{}' and code={} and end_time='0000-00-00 00:00:00'
+                                '''.format(datetime.datetime.now(), df_fault_ram_sn.iloc[-1]['end_time'], df_fault_ram_sn.iloc[-1]['Batpos'],sn, 110))
                         conn_platform.commit()
                     except:
                         logger.error(traceback.format_exc)
@@ -234,7 +235,7 @@ if __name__ == "__main__":
     password='Qixiang2021'
     conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
     cursor = conn.cursor()
-    cursor.execute("select sn, imei, add_time from app_device")
+    cursor.execute("select sn, imei, add_time from app_device where status in (1,2,3)")
     res = cursor.fetchall()
     df_sn = pd.DataFrame(res, columns=['sn', 'imei', 'add_time'])
     df_sn = df_sn.reset_index(drop=True)
@@ -296,7 +297,7 @@ if __name__ == "__main__":
     saftywarning_cal()
     #定时任务.......................................................................................................................................................................
     scheduler = BlockingScheduler()
-    scheduler.add_job(saftywarning_cal, 'interval', seconds=12*3600, id='saftywarning_cal')
+    scheduler.add_job(saftywarning_cal, 'interval', hours=6, id='saftywarning_cal')
 
     try:  
         scheduler.start()

+ 4 - 1
LIB/FRONTEND/CellStateEstimation/SOH/deploy.py

@@ -82,6 +82,7 @@ if __name__ == "__main__":
 
     for i in range(0, len(df_sn)):
         try:
+            sn = df_sn.loc[i, 'sn']
             if df_sn.loc[i, 'imei'][5:9] == 'N640':
                 celltype=1 #6040三元电芯
             elif df_sn.loc[i, 'imei'][5:9] == 'N440':
@@ -90,12 +91,14 @@ if __name__ == "__main__":
                 celltype=99 # 6060锂电芯
             elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
                 celltype=3 #力信 50ah三元电芯
+            elif df_sn.loc[i, 'imei'][3:9] == 'CLL128':    
+                celltype=100 # 重卡
             elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
                 celltype=4 #CATL 50ah三元电芯
             else:
                 logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
                 continue
-            sn = df_sn.loc[i, 'sn']
+           
             
             logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))
             dbManager = DBManager.DBManager()

+ 4 - 4
LIB/FRONTEND/SaftyCenter/DataDiag_Static/deploy.py

@@ -49,11 +49,11 @@ def diag_cal():
     #............................模块运行前,先读取数据库中所有结束时间为0的数据,需要从数据库中读取................``
     # print("select start_time, end_time, product_id, code, level, info, advice, factory from {}".format(tablename))
     try:
-        df_Diag_Ram=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice, Batpos from all_fault_info", db_engine)
+        df_Diag_Ram=pd.read_sql("select start_time, end_time, product_id, code, level, info, advice, Batpos from all_fault_info where end_time='0000-00-00 00:00:00' ", db_engine)
     finally:
         db_engine.dispose()
-    df_Diag_Ram=df_Diag_Ram.dropna(axis=1,how='any')
-    df_Diag_Ram=df_Diag_Ram.reset_index(drop=True)    
+    # df_Diag_Ram=df_Diag_Ram.dropna(axis=1,how='any')
+    # df_Diag_Ram=df_Diag_Ram.reset_index(drop=True)    
     #读取结果数据库数据........................................................................................................................................................
     host1='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
     port1=3306
@@ -407,7 +407,7 @@ if __name__ == "__main__":
     password='qx@123456'
     conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
     cursor = conn.cursor()
-    cursor.execute("select sn, imei, add_time from app_device")
+    cursor.execute("select sn, imei, add_time from app_device where status in (1,2,3)")
     res = cursor.fetchall()
     df_sn = pd.DataFrame(res, columns=['sn', 'imei', 'add_time'])
     df_sn = df_sn.reset_index(drop=True)

+ 2 - 0
LIB/FRONTEND/SaftyCenter/Liplated/deploy.py

@@ -53,6 +53,8 @@ def cell_platd_sorvol_test(df_sn):
                 celltype=99 # 6060锂电芯
             elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
                 celltype=3 #力信 50ah三元电芯
+            elif df_sn.loc[i, 'imei'][3:9] == 'CLL128':    
+                celltype=100 # 重卡
             elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
                 celltype=4 #CATL 50ah三元电芯
             else:

+ 5 - 3
LIB/FRONTEND/SaftyCenter/LowSocAlarm/deploy.py

@@ -102,11 +102,13 @@ if __name__ == "__main__":
                     celltype=99 # 6060锂电芯
                 elif df_sn.loc[i, 'imei'][3:5] == 'LX' and df_sn.loc[i, 'imei'][5:9] == 'N750':    
                     celltype=3 #力信 50ah三元电芯
+                elif df_sn.loc[i, 'imei'][3:9] == 'CLL128':    
+                    celltype=100 # 重卡
                 elif df_sn.loc[i, 'imei'][3:5] == 'CL' and df_sn.loc[i, 'imei'][5:9] == 'N750': 
                     celltype=4 #CATL 50ah三元电芯
-                else:
-                    logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
-                    continue
+                # else:
+                #     logger.info("pid-{} celltype-{} SN: {} SKIP!".format(os.getpid(), "未知", sn))
+                #     continue
                 sn = df_sn.loc[i, 'sn']
                 param=QX_BatteryParam.BatteryInfo(celltype) 
                 logger.info("pid-{} celltype-{} SN: {} START!".format(os.getpid(), celltype, sn))

+ 14 - 1
LIB/FRONTEND/SaftyCenter/Offline/deploy.py

@@ -52,9 +52,20 @@ if __name__ == "__main__":
             "mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8".format(
                 user, parse.quote_plus(password), host, port, db
             ))
+        host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+        port=3306
+        db='qixiang_manage'
+        user='qx_query'
+        password='@Qx_query'
+
+        conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
+        cursor = conn.cursor()
+        cursor.execute("select qrcode from py_battery where status=3")
+        res = cursor.fetchall()
+        ignore_sns = pd.DataFrame(res, columns=['sn'])['sn'].tolist()
 
         logger.info("pid-{}   START!".format(os.getpid()))
-        offline_alarm.offline_alarm(db_iotp_engine, db_qxcas_engine)
+        offline_alarm.offline_alarm(db_iotp_engine, db_qxcas_engine, ignore_sns)
         logger.info("pid-{} DONE!".format(os.getpid()))
                     
     except:
@@ -63,4 +74,6 @@ if __name__ == "__main__":
 
     db_iotp_engine.dispose()
     db_qxcas_engine.dispose()
+    cursor.close()
+    conn.close
     

+ 33 - 7
LIB/FRONTEND/SaftyCenter/status_sta/deploy.py

@@ -45,15 +45,27 @@ if __name__ == "__main__":
         host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
         port=3306
         db='qixiang_oss'
-        user='qixiang_oss'
-        password='Qixiang2021'
+        user='qx_algo_rw'
+        password='qx@123456'
         conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
         cursor = conn.cursor()
-        cursor.execute("select sn, imei, add_time from app_device")
+        cursor.execute("select sn, imei, add_time from app_device where status in (1,2,3)")
         res = cursor.fetchall()
         df_sn = pd.DataFrame(res, columns=['sn', 'imei', 'add_time'])
         df_sn = df_sn.reset_index(drop=True)
+        cursor.close()
         conn.close();
+        df_sn['factory'] = '骑享'
+        
+        # db = 'qx_cas'
+        # conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
+        # cursor = conn.cursor()
+        # cursor.execute("select sn, factory from sn_list")
+        # res = cursor.fetchall()
+        # df_sn2 = pd.DataFrame(res, columns=['sn', 'factory'])
+        # df_sn2['imei'] = ""
+        # df_sn = pd.concat([df_sn, df_sn2], axis=0)
+        # df_sn = df_sn.reset_index(drop=True)
         
         # 数据库配置
         host = 'rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
@@ -90,26 +102,40 @@ if __name__ == "__main__":
     charge_count = 0
     drive_count = 0
     stand_count = 0
-    for sn in df_sn['sn'].tolist():
+    charge_count_jinmao = 0
+    drive_count_jinmao = 0
+    stand_count_jinmao = 0
+    for i in range(0, len(df_sn)):
+        sn = df_sn.loc[i, 'sn']
         try:
             logger.info("pid-{}  SN: {} START!".format(os.getpid(), sn))
             df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms', 'gps'])
-            
             df_bms = df_data['bms']
             df_gps = df_data['gps']
-            charge_count, drive_count, stand_count = status_sta.status_sta(df_bms, df_gps, start_time, charge_count, drive_count, stand_count)
-            df_result = pd.DataFrame({'factory':['骑享'], 'time':[start_time], 'charge_count':[charge_count], 'drive_count':[drive_count], 'stand_count':stand_count})
+            if df_sn.loc[i, 'imei'][3:9] == 'CLL128':    
+                factory = '金茂'
+                charge_count_jinmao, drive_count_jinmao, stand_count_jinmao = status_sta.status_sta(df_bms, df_gps, start_time, charge_count_jinmao, drive_count_jinmao, stand_count_jinmao, factory)
+            else:
+                factory = '骑享'
+                charge_count, drive_count, stand_count = status_sta.status_sta(df_bms, df_gps, start_time, charge_count, drive_count, stand_count)
+            
 
             logger.info("pid-{}  SN: {} DONE!".format(os.getpid(), sn))
                         
         except:
             logger.error(traceback.format_exc)
             logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)
+    df_result = pd.DataFrame({'factory':['骑享'], 'time':[start_time], 'charge_count':[charge_count], 'drive_count':[drive_count], 'stand_count':stand_count})
+    df_result_jinmao = pd.DataFrame({'factory':['金茂换电'], 'time':[start_time], 'charge_count':[charge_count_jinmao], 'drive_count':[drive_count_jinmao], 'stand_count':stand_count_jinmao})
     try:
         if not df_result.empty:
             df_result.columns = ['factory', 'time', 'charge_count', 'drive_count', 'stand_count']
             df_result.to_sql("period_status_statistic",con=db_res_engine, if_exists="append",index=False)
             logger.info("数据库写入成功!")
+        if not df_result_jinmao.empty:
+            df_result_jinmao.columns = ['factory', 'time', 'charge_count', 'drive_count', 'stand_count']
+            df_result_jinmao.to_sql("period_status_statistic",con=db_res_engine, if_exists="append",index=False)
+            logger.info("数据库写入成功!")
     except:
         logger.error(traceback.format_exc)
         logger.error(u"{} :{},{} 任务运行错误\n".format(sn,start_time,end_time), exc_info=True)

+ 19 - 0
LIB/FRONTEND/other/oss_to_iotp/deploy.py

@@ -73,6 +73,25 @@ if __name__ == "__main__":
         filt_sns = df_filt['sn'].tolist()
         sns = list(set(all_sns)-set(filt_sns))
         df_res = pd.DataFrame({'sn':sns})
+        df_res['factory'] = '骑享'
+        
+        
+        # 金茂换电sn列表
+        # 更新sn列表
+        host='rm-bp10j10qy42bzy0q7.mysql.rds.aliyuncs.com'
+        port=3306
+        db='qixiang_oss'
+        user='qx_algo_rw'
+        password='qx@123456'
+        db = 'qx_cas'
+        conn = pymysql.connect(host=host, port=port, user=user, password=password, database=db)
+        cursor = conn.cursor()
+        cursor.execute("select sn, factory from sn_list")
+        res = cursor.fetchall()
+        df_sn2 = pd.DataFrame(res, columns=['sn', 'factory'])
+        df_sn2['factory'] = "金茂换电"
+        df_res = pd.concat([df_res, df_sn2], axis=0)
+        df_res = df_res.reset_index(drop=True)
         
     
         df_res.to_sql("operation_sn",con=db_engine, if_exists="replace",index=False)