|
@@ -53,7 +53,12 @@ if __name__ == "__main__":
|
|
|
continue
|
|
|
st = df_sn.loc[i, 'StartTime']
|
|
|
if df_sn.loc[i, 'Service'] == 0:
|
|
|
- et = df_sn.loc[i, 'ExitTime']
|
|
|
+ if pd.isnull(df_sn.loc[i, 'EndTime']) and pd.isnull(df_sn.loc[i, 'ExitTime']):
|
|
|
+ continue
|
|
|
+ elif pd.isnull(df_sn.loc[i, 'ExitTime']):
|
|
|
+ et = df_sn.loc[i, 'EndTime']
|
|
|
+ else:
|
|
|
+ et = df_sn.loc[i, 'ExitTime']
|
|
|
elif pd.isnull(df_sn.loc[i, 'EndTime']):
|
|
|
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
|
|
et = pd.to_datetime(otherStyleTime)
|
|
@@ -87,12 +92,10 @@ if __name__ == "__main__":
|
|
|
df_tosql = df_last_state.copy()
|
|
|
df_tosql.columns = ['sn', 'current', 'time_stamp', 'pack_state', 'line_state']
|
|
|
df_tosql.to_sql("bms_last_data_day",con=db_engine, if_exists="append",index=False)
|
|
|
- print(df_tosql)
|
|
|
|
|
|
df_tosql = df_last_state_gps.copy()
|
|
|
df_tosql.columns = ['sn', 'time_stamp', 'pack_state', 'line_state']
|
|
|
df_tosql.to_sql("gps_last_data_day",con=db_engine, if_exists="append",index=False)
|
|
|
- print(df_tosql)
|
|
|
|
|
|
logger.info("{} {} Success!".format(sn, str(st)))
|
|
|
except Exception as e:
|