main.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import pandas as pd
  2. import datetime
  3. import pymysql
  4. import log
  5. from LIB.BACKEND import DBManager, Log
  6. from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import DBDownload
  7. if __name__ == "__main__":
  8. end_time=datetime.datetime.now()-datetime.timedelta(seconds=10)
  9. start_time=end_time-datetime.timedelta(seconds=12000)
  10. start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
  11. end_time=end_time.strftime('%Y-%m-%d %H:%M:%S')
  12. start_time = pd.to_datetime('2021-09-01 12:00:00',format='%Y-%m-%d %H:%M:%S')
  13. end_time = pd.to_datetime('2021-11-01 12:00:00',format='%Y-%m-%d %H:%M:%S')
  14. excelpath=r'D:\Develop\User\Liuzhongxiao\data_analyze_platform\USER\01算法开发\00项目sn号\sn-20210903.xlsx'
  15. SNdata_6060 = pd.read_excel(excelpath, sheet_name='科易6060')
  16. SNdata_6040 = pd.read_excel(excelpath, sheet_name='科易6040')
  17. SNdata_4840 = pd.read_excel(excelpath, sheet_name='科易4840')
  18. SNdata_L7255 = pd.read_excel(excelpath, sheet_name='格林美-力信7255')
  19. SNdata_C7255 = pd.read_excel(excelpath, sheet_name='格林美-CATL7255')
  20. SNdata_U7255 = pd.read_excel(excelpath, sheet_name='优旦7255')
  21. SNnums_6060=SNdata_6060['SN号'].tolist()
  22. SNnums_6040=SNdata_6040['SN号'].tolist()
  23. SNnums_4840=SNdata_4840['SN号'].tolist()
  24. SNnums_L7255=SNdata_L7255['SN号'].tolist()
  25. SNnums_C7255=SNdata_C7255['SN号'].tolist()
  26. SNnums_U7255=SNdata_U7255['SN号'].tolist()
  27. # SNnums= SNnums_6060#SNnums_L7255 + SNnums_C7255 + SNnums_U7255, SNnums_6040 + SNnums_4840 + SNnums_6060
  28. SNnums=['PK504B00100004003']
  29. # SNnums_data = pd.read_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\02析锂分析\各项目析锂情况_211130\增加波峰高度与峰谷比计算结果\SNnums_C7255析锂情况析锂排序.csv',encoding='GB18030')
  30. # SNnums_len = len(SNnums_data)
  31. # SNnums = SNnums_data['sn'][SNnums_len-11:SNnums_len]
  32. #log信息配置
  33. mylog=log.Mylog('log.txt','error')
  34. mylog.logcfg()
  35. # df_li_plated = pd.DataFrame(columns = ['sn','time','liplated','liplated_amount'])
  36. k = 1
  37. for sn in SNnums:
  38. try:
  39. # celltype=4
  40. # sn=SNnums[2]
  41. print('下载数据中,第' + str(k) + '个:' + sn)
  42. #下载数据库..........................................................................................................................................
  43. # host='rm-bp10j10qy42bzy0q77o.mysql.rds.aliyuncs.com'
  44. # port=3306
  45. # db='qx_cas'
  46. # user='qx_algo_readonly'
  47. # password='qx@123456'
  48. # mode = 2
  49. # tablename='cellstateestimation_soh'
  50. # DBRead=DBDownload.DBDownload(host, port, db, user, password, mode)
  51. # with DBRead as DBRead:
  52. # df_cell_soh=DBRead.getdata(param='sn,time_sp,soh,cellsoh', tablename=tablename, sn=sn, timename='time_sp', st=start_time, sp=end_time)
  53. # # df_li_plated = df_li_plated.append(df_cell_li_plated)
  54. # if not df_cell_soh.empty:
  55. # df_cell_soh.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\02析锂分析\各项目析锂情况_211130\增加波峰高度与峰谷比计算结果\析锂排序后10模组的soh\\'+ sn + '.csv', encoding='GB18030')
  56. #下载原始数据------------------------------------------------------------------------------------------------------------------------------------
  57. start_time = '2021-11-01 00:00:00'
  58. end_time = '2021-12-04 00:00:00'
  59. dbManager = DBManager.DBManager()
  60. df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
  61. df_bms = df_data['bms']
  62. # df_bms.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\01下载数据\金茂\原始数据\\'+sn+'.csv', encoding='GB18030')
  63. df_bms.to_csv(r'D:\Develop\User\Liuzhongxiao\data_analyze_platform\USER\02问题查询\PK504B\PK504B00100004003.csv', encoding='GB18030')
  64. k = k + 1
  65. # if not df_bms.empty:
  66. # BatInterShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms)
  67. # df_res=BatInterShort.intershort()
  68. #df_res.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\04didi\99Result\\'+'CBMS_InterShort'+sn[3:10]+'.xlsx')
  69. # print(sn,'done!!!')
  70. print(sn)
  71. except IndexError as e:
  72. print(repr(e))
  73. mylog.logopt(sn,e)
  74. pass
  75. # df_li_plated.to_csv(r'D:\Work\Code_write\data_analyze_platform\USER\lzx\01算法开发\02析锂检测\02析锂分析\各项目析锂情况_211130\析锂状态.csv', encoding='GB18030')