Browse Source

fltlvl获取值变为数值

Eric412V 3 years ago
parent
commit
6c60207d0e

+ 1 - 0
LIB/MIDDLE/SaftyCenter/DataSta/DataStatistics.py

@@ -58,6 +58,7 @@ class DataSta():
         FaultLvlCount=DataFrame(columns=['level','count'])
         FaultLvlCount=df_fltinfo.groupby('level').count().T.head(1).T
         FaultLvlCount=FaultLvlCount.reset_index(drop=False)
+        
         return FaultLvlCount
     def SftyWrngClsfy(df_fltinfo):
         DsnSaftyCode=[]

+ 8 - 12
LIB/MIDDLE/SaftyCenter/DataSta/main.py

@@ -35,20 +35,16 @@ def Week_Task():
     end_time=end_time.strftime('%Y-%m-%d')
     FltAlarmInfo,Celltype=DataSta.SaftyWarningSta(CS_Data,df_fltinfo,start_time,end_time)
     FaultLvlCount=DataSta.WeekInfoSta(df_fltinfo,start_time,end_time)
-    lvl1=FaultLvlCount[FaultLvlCount['level']==1]['product_id'].values
-    lvl2=FaultLvlCount[FaultLvlCount['level']==2]['product_id'].values
-    lvl3=FaultLvlCount[FaultLvlCount['level']==3]['product_id'].values
-    lvl4=FaultLvlCount[FaultLvlCount['level']==4]['product_id'].values
-    lvl5=FaultLvlCount[FaultLvlCount['level']==5]['product_id'].values
+    for i in range(1,6):
+        if not FaultLvlCount[FaultLvlCount['level']==i]['product_id'].empty:
+            all_period_fault_info.loc[0,'level'+str(i)+'_count']=int(FaultLvlCount[FaultLvlCount['level']==i]['product_id'].values)
+        else:
+            all_period_fault_info.loc[0,'level'+str(i)+'_count']=int(0)
     all_period_fault_info.loc[0,'factory']='骑享'
     all_period_fault_info.loc[0,'week']=toweek
-    all_period_fault_info.loc[0,'level1_count']=lvl1
-    all_period_fault_info.loc[0,'level2_count']=lvl2
-    all_period_fault_info.loc[0,'level3_count']=lvl3
-    all_period_fault_info.loc[0,'level4_count']=lvl4
-    all_period_fault_info.loc[0,'level5_count']=lvl5
     all_period_fault_info.loc[0,'solve_rate']=FltAlarmInfo.loc[0,'OprationManageRate']
-    
+    all_period_fault_info.fillna(0,inplace=False)
+    print(all_period_fault_info)
 def Minutes_Task():
     
     #............................获取数据................................
@@ -129,7 +125,7 @@ def Minutes_Task():
     all_statistic_info.loc[0,'controller_safety_risk_count']=SatftyCount.loc[0,'CtrlSaftyCodeCount']
     all_statistic_info.loc[0,'design_safety_risk_count']=SatftyCount.loc[0,'DsnSaftyCodeCount']
 #定时任务....................................................................................................................................................................... 
-#Week_Task()
+Week_Task()
 Minutes_Task()
 scheduler = BlockingScheduler()
 scheduler.add_job(Week_Task, 'interval', days=7, id='Week_Task')

BIN
df_file.xlsx