2 Commits f291778ca9 ... 69907e3c5a

Author SHA1 Message Date
  zhuxi 69907e3c5a Merge branch 'dev' of http://git.fast-fun.cn:92/lmstack/data_analyze_platform into dev 2 years ago
  zhuxi 2f6cba1dab debug main core 0815 2 years ago

+ 8 - 4
LIB/MIDDLE/InfoChrgDrive/Charge/V1_0_0/coreV0.py

@@ -336,7 +336,7 @@ def change_new(df_sts_chrg,chrg_last):
     if len(chrg_last)>0:
         time_last=chrg_last['time_end']
         time_first=df_sts_chrg.loc[0,'time_st']
-        time_last=datetime.datetime.strptime(time_last,'%Y-%m-%d %H:%M:%S')
+        time_last=datetime.datetime.strptime(str(time_last),'%Y-%m-%d %H:%M:%S')
         if (chrg_last['status']==df_sts_chrg.loc[0,'status']) & ((time_first-time_last).total_seconds()/60<10) & \
             (round(chrg_last['gps_lat'],2)==round(df_sts_chrg.loc[0,'gps_lat'],2)) & \
             (round(chrg_last['gps_lon'],2)==round(df_sts_chrg.loc[0,'gps_lon'],2)) :
@@ -349,8 +349,6 @@ def change_new(df_sts_chrg,chrg_last):
             chrg_last['temp_min']=np.min([df_sts_chrg.loc[0,'temp_min'],chrg_last['temp_min']])
             chrg_last['temp_incr']=df_sts_chrg.loc[0,'temp_incr']+chrg_last['temp_incr']
             chrg_last['temp_mean']=round(np.mean([df_sts_chrg.loc[0,'temp_mean'],chrg_last['temp_mean']]),1)
-            #chrg_last['temp_end_max']=df_sts_chrg.loc[0,'temp_end_max']
-            #chrg_last['temp_end_min']=df_sts_chrg.loc[0,'temp_end_min']
             chrg_last['temp_end_mean']=df_sts_chrg.loc[0,'temp_end_mean']
             chrg_last['difftem_max']=np.max([df_sts_chrg.loc[0,'difftem_max'],chrg_last['difftem_max']])
             delta_soc=chrg_last['soc_end']-chrg_last['soc_st']
@@ -425,7 +423,13 @@ 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,chrg_last):
+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]
     new=pd.DataFrame()
     change=pd.DataFrame()
     if len(df_merge)>0:

+ 2 - 8
LIB/MIDDLE/InfoChrgDrive/Charge/main_V0.py

@@ -67,16 +67,10 @@ 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.Series()
+                df_diag_ram_sn=pd.DataFrame()
                 if not df_diag_ram.empty:   #结果库非空
                     df_diag_ram_sn=df_diag_ram[df_diag_ram['sn']==sn]
-                    if not df_diag_ram_sn.empty:   #该sn相关结果非空
-                        df_diag_ram_sn.reset_index(inplace=True,drop=True)
-                        df_diag_ram_sn['time_end']=list(map(lambda x: datetime.datetime.strptime(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=df_diag_ram_sn.iloc[-1]
-                        time_end =df_diag_ram_sn['time_end']
-                        df_diag_ram_sn.reset_index(inplace=True,drop=True)
+
                 df_diag_new,df_diag_change=pro_output(df_merge,sn,gpscity,df_diag_ram_sn)
                 kmeans1 = joblib.load('kmeans1.pkl')
                 kmeans2 = joblib.load('kmeans2.pkl')