|
@@ -3,32 +3,20 @@ import pymysql
|
|
|
import datetime
|
|
|
import pandas as pd
|
|
|
import multiprocessing
|
|
|
-from LIB.BACKEND import DBManager, Log
|
|
|
+from LIB.BACKEND import DBManager
|
|
|
import time, datetime
|
|
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
|
|
from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import log
|
|
|
|
|
|
|
|
|
#...................................电池包电芯安全诊断函数......................................................................................................................
|
|
|
-<<<<<<< HEAD
|
|
|
def diag_cal(sn_list, df_bms_ram, df_alarm_ram,now_time):
|
|
|
|
|
|
start=time.time()
|
|
|
end_time=now_time
|
|
|
- start_time=now_time-datetime.timedelta(seconds=60)
|
|
|
+ start_time=now_time-datetime.timedelta(seconds=70)
|
|
|
start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
end_time=now_time.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
-=======
|
|
|
-def diag_cal(sn_list, df_bms_ram, df_alarm_ram):
|
|
|
-
|
|
|
- start=time.time()
|
|
|
- now_time=datetime.datetime.now() #-datetime.timedelta(seconds=3600*24+3600*14.6)
|
|
|
- start_time=now_time-datetime.timedelta(seconds=180)
|
|
|
- start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
- end_time=now_time.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
- start_time='2021-10-31 09:30:30'
|
|
|
- end_time='2021-10-31 09:31:30'
|
|
|
->>>>>>> master
|
|
|
|
|
|
#数据库配置
|
|
|
host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
|
|
@@ -108,12 +96,9 @@ def diag_cal(sn_list, df_bms_ram, df_alarm_ram):
|
|
|
return df_bms_ram,df_alarm_ram
|
|
|
#...................................................主进程...........................................................................................................
|
|
|
def mainprocess():
|
|
|
-<<<<<<< HEAD
|
|
|
global df_bms_ram1, df_bms_ram2, df_alarm_ram1, df_alarm_ram2, SNnums, now_time
|
|
|
now_time=now_time+datetime.timedelta(seconds=60)
|
|
|
-=======
|
|
|
- global df_bms_ram1, df_bms_ram2, df_alarm_ram1, df_alarm_ram2, SNnums
|
|
|
->>>>>>> master
|
|
|
+
|
|
|
process = 2
|
|
|
pool = multiprocessing.Pool(processes = process)
|
|
|
|
|
@@ -124,11 +109,7 @@ def mainprocess():
|
|
|
sn_list = SNnums[i]
|
|
|
df_bms_ram=ram_list1[i]
|
|
|
df_alarm_ram=ram_list2[i]
|
|
|
-<<<<<<< HEAD
|
|
|
df_res=pool.apply_async(diag_cal, (sn_list,df_bms_ram,df_alarm_ram,now_time)).get()
|
|
|
-=======
|
|
|
- df_res=pool.apply_async(diag_cal, (sn_list,df_bms_ram,df_alarm_ram)).get()
|
|
|
->>>>>>> master
|
|
|
res_list.append(df_res)
|
|
|
|
|
|
pool.close()
|
|
@@ -142,7 +123,6 @@ def mainprocess():
|
|
|
#...............................................主函数起定时作用.......................................................................................................................
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
-<<<<<<< HEAD
|
|
|
# excelpath=r'D:\Develop\User\Songpengfei\data_analyze_platform\WORK\01qixiang\sn-20210903.xlsx'
|
|
|
# SNdata_6060 = pd.read_excel(excelpath, sheet_name='科易6060')
|
|
|
# SNdata_6040 = pd.read_excel(excelpath, sheet_name='科易6040')
|
|
@@ -157,25 +137,8 @@ if __name__ == "__main__":
|
|
|
# SNnums_C7255=SNdata_C7255['SN号'].tolist()
|
|
|
# SNnums_U7255=SNdata_U7255['SN号'].tolist()
|
|
|
# SNnums=[SNnums_L7255 + SNnums_C7255 + SNnums_U7255 + SNnums_4840, SNnums_6040 + SNnums_6060]
|
|
|
- SNnums=[['PK504B10100004487'], []]
|
|
|
- now_time=datetime.datetime.strptime('2022-5-24 19:49:00','%Y-%m-%d %H:%M:%S')
|
|
|
-=======
|
|
|
- excelpath=r'D:\Develop\User\Songpengfei\data_analyze_platform\WORK\01qixiang\sn-20210903.xlsx'
|
|
|
- SNdata_6060 = pd.read_excel(excelpath, sheet_name='科易6060')
|
|
|
- SNdata_6040 = pd.read_excel(excelpath, sheet_name='科易6040')
|
|
|
- SNdata_4840 = pd.read_excel(excelpath, sheet_name='科易4840')
|
|
|
- SNdata_L7255 = pd.read_excel(excelpath, sheet_name='格林美-力信7255')
|
|
|
- SNdata_C7255 = pd.read_excel(excelpath, sheet_name='格林美-CATL7255')
|
|
|
- SNdata_U7255 = pd.read_excel(excelpath, sheet_name='优旦7255')
|
|
|
- SNnums_6060=SNdata_6060['SN号'].tolist()
|
|
|
- SNnums_6040=SNdata_6040['SN号'].tolist()
|
|
|
- SNnums_4840=SNdata_4840['SN号'].tolist()
|
|
|
- SNnums_L7255=SNdata_L7255['SN号'].tolist()
|
|
|
- SNnums_C7255=SNdata_C7255['SN号'].tolist()
|
|
|
- SNnums_U7255=SNdata_U7255['SN号'].tolist()
|
|
|
- SNnums=[SNnums_L7255 + SNnums_C7255 + SNnums_U7255 + SNnums_4840, SNnums_6040 + SNnums_6060]
|
|
|
- SNnums=[['MGMCLN750N215N049','PK504B10100004328'], ['PK500A20100000752','PK504B10100004387']]
|
|
|
->>>>>>> master
|
|
|
+ SNnums=[['PK504B10100004312'], []]
|
|
|
+ now_time=datetime.datetime.strptime('2022-8-11 9:22:00','%Y-%m-%d %H:%M:%S')
|
|
|
|
|
|
mylog=log.Mylog('log_diag.txt','error')
|
|
|
mylog.logcfg()
|
|
@@ -186,14 +149,12 @@ if __name__ == "__main__":
|
|
|
df_alarm_ram1=pd.DataFrame(columns=['sn','time','safetywarning1','safetywarning2'])
|
|
|
df_alarm_ram2=pd.DataFrame(columns=['sn','time','safetywarning1','safetywarning2'])
|
|
|
|
|
|
- mainprocess()
|
|
|
+ # mainprocess()
|
|
|
#定时任务.......................................................................................................................................................................
|
|
|
scheduler = BlockingScheduler()
|
|
|
-<<<<<<< HEAD
|
|
|
- scheduler.add_job(mainprocess, 'interval', seconds=0.1, id='diag_job')
|
|
|
-=======
|
|
|
- scheduler.add_job(mainprocess, 'interval', seconds=180, id='diag_job')
|
|
|
->>>>>>> master
|
|
|
+
|
|
|
+ scheduler.add_job(mainprocess, 'interval', seconds=1, id='diag_job')
|
|
|
+
|
|
|
|
|
|
try:
|
|
|
scheduler.start()
|