zhuxi 2 jaren geleden
bovenliggende
commit
0581daf070
2 gewijzigde bestanden met toevoegingen van 10 en 10 verwijderingen
  1. 1 7
      LIB/MIDDLE/InfoChrgDrive/Charge/V1_0_0/coreV0.py
  2. 9 3
      LIB/MIDDLE/InfoChrgDrive/Charge/main_V0.py

+ 1 - 7
LIB/MIDDLE/InfoChrgDrive/Charge/V1_0_0/coreV0.py

@@ -423,13 +423,7 @@ def mkdf_chrg(chrg,data_new,param):
         df_sts_chrg=df_sts_chrg.append(df_sts_chrg_temp)
     return df_sts_chrg
 
-def pro_output(df_merge,sn,gpscity,df_diag_ram_sn):
-    chrg_last=pd.Series()
-    if len(df_diag_ram_sn)>0:
-        df_diag_ram_sn['time_end']=list(map(lambda x: datetime.datetime.strptime(str(x),'%Y-%m-%d %H:%M:%S'),list(df_diag_ram_sn['time_end'])))
-        df_diag_ram_sn = df_diag_ram_sn.sort_values(by = 'time_end')
-        df_diag_ram_sn.reset_index(inplace=True,drop=True)
-        chrg_last=df_diag_ram_sn.iloc[-1]
+def pro_output(df_merge,sn,gpscity,chrg_last):
     new=pd.DataFrame()
     change=pd.DataFrame()
     if len(df_merge)>0:

+ 9 - 3
LIB/MIDDLE/InfoChrgDrive/Charge/main_V0.py

@@ -67,11 +67,17 @@ def diag_cal():
             if not df_bms.empty:   #BMS数据非空
                 df_merge=pd.merge(df_bms,df_gps,how='outer',sort=True)
                 df_merge['sn']=sn
-                df_diag_ram_sn=pd.DataFrame()
+                chrg_last=pd.Series()
                 if not df_diag_ram.empty:   #结果库非空
                     df_diag_ram_sn=df_diag_ram[df_diag_ram['sn']==sn]
-
-                df_diag_new,df_diag_change=pro_output(df_merge,sn,gpscity,df_diag_ram_sn)
+                    if not df_diag_ram_sn.empty: 
+                        df_diag_ram_sn['time_end']=list(map(lambda x: datetime.datetime.strptime(str(x),'%Y-%m-%d %H:%M:%S'),list(df_diag_ram_sn['time_end'])))
+                        df_diag_ram_sn = df_diag_ram_sn.sort_values(by = 'time_end')
+                        df_diag_ram_sn.reset_index(inplace=True,drop=True)
+                        chrg_last=df_diag_ram_sn.iloc[-1]
+                        time_end=chrg_last['time_end']
+
+                df_diag_new,df_diag_change=pro_output(df_merge,sn,gpscity,chrg_last)
                 kmeans1 = joblib.load('kmeans1.pkl')
                 kmeans2 = joblib.load('kmeans2.pkl')
                 kmeans3 = joblib.load('kmeans3.pkl')