0e55233e by 周伟奇

fix idcard daily

1 parent dcc1396d
......@@ -2,7 +2,7 @@ import re
import os
import ast
import datetime
from openpyxl import Workbook
from openpyxl import Workbook, load_workbook
from django.core.management import BaseCommand
from settings import conf
from common.mixins import LoggerMixin
......@@ -48,11 +48,22 @@ class Command(BaseCommand, LoggerMixin):
print('log_path not exists')
return
afc_excel_path = os.path.join(afc_excel_dir, 'idcard_{0}.xlsx'.format(date_str))
hil_excel_path = os.path.join(hil_excel_dir, 'idcard_{0}.xlsx'.format(date_str))
if os.path.isfile(afc_excel_path):
wb_afc = load_workbook(afc_excel_path)
ws_afc = wb_afc.get_sheet_by_name(self.sheet_name)
else:
wb_afc = Workbook()
ws_afc = wb_afc.create_sheet(self.sheet_name)
ws_afc.append(self.header)
wb_afc.remove(wb_afc.get_sheet_by_name('Sheet'))
if os.path.isfile(hil_excel_path):
wb_hil = load_workbook(hil_excel_path)
ws_hil = wb_hil.get_sheet_by_name(self.sheet_name)
else:
wb_hil = Workbook()
ws_hil = wb_hil.create_sheet(self.sheet_name)
ws_hil.append(self.header)
......@@ -87,7 +98,5 @@ class Command(BaseCommand, LoggerMixin):
for id_num, nation in content_list:
ws_afc.append((application_id[0], id_num, nation, time_str))
afc_excel_path = os.path.join(afc_excel_dir, 'idcard_{0}.xlsx'.format(date_str))
hil_excel_path = os.path.join(hil_excel_dir, 'idcard_{0}.xlsx'.format(date_str))
wb_afc.save(afc_excel_path)
wb_hil.save(hil_excel_path)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!