fix idcard daily
Showing
1 changed file
with
12 additions
and
3 deletions
... | @@ -2,7 +2,7 @@ import re | ... | @@ -2,7 +2,7 @@ import re |
2 | import os | 2 | import os |
3 | import ast | 3 | import ast |
4 | import datetime | 4 | import datetime |
5 | from openpyxl import Workbook | 5 | from openpyxl import Workbook, load_workbook |
6 | from django.core.management import BaseCommand | 6 | from django.core.management import BaseCommand |
7 | from settings import conf | 7 | from settings import conf |
8 | from common.mixins import LoggerMixin | 8 | from common.mixins import LoggerMixin |
... | @@ -48,11 +48,22 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -48,11 +48,22 @@ class Command(BaseCommand, LoggerMixin): |
48 | print('log_path not exists') | 48 | print('log_path not exists') |
49 | return | 49 | return |
50 | 50 | ||
51 | afc_excel_path = os.path.join(afc_excel_dir, 'idcard_{0}.xlsx'.format(date_str)) | ||
52 | hil_excel_path = os.path.join(hil_excel_dir, 'idcard_{0}.xlsx'.format(date_str)) | ||
53 | |||
54 | if os.path.isfile(afc_excel_path): | ||
55 | wb_afc = load_workbook(afc_excel_path) | ||
56 | ws_afc = wb_afc.get_sheet_by_name(self.sheet_name) | ||
57 | else: | ||
51 | wb_afc = Workbook() | 58 | wb_afc = Workbook() |
52 | ws_afc = wb_afc.create_sheet(self.sheet_name) | 59 | ws_afc = wb_afc.create_sheet(self.sheet_name) |
53 | ws_afc.append(self.header) | 60 | ws_afc.append(self.header) |
54 | wb_afc.remove(wb_afc.get_sheet_by_name('Sheet')) | 61 | wb_afc.remove(wb_afc.get_sheet_by_name('Sheet')) |
55 | 62 | ||
63 | if os.path.isfile(hil_excel_path): | ||
64 | wb_hil = load_workbook(hil_excel_path) | ||
65 | ws_hil = wb_hil.get_sheet_by_name(self.sheet_name) | ||
66 | else: | ||
56 | wb_hil = Workbook() | 67 | wb_hil = Workbook() |
57 | ws_hil = wb_hil.create_sheet(self.sheet_name) | 68 | ws_hil = wb_hil.create_sheet(self.sheet_name) |
58 | ws_hil.append(self.header) | 69 | ws_hil.append(self.header) |
... | @@ -87,7 +98,5 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -87,7 +98,5 @@ class Command(BaseCommand, LoggerMixin): |
87 | for id_num, nation in content_list: | 98 | for id_num, nation in content_list: |
88 | ws_afc.append((application_id[0], id_num, nation, time_str)) | 99 | ws_afc.append((application_id[0], id_num, nation, time_str)) |
89 | 100 | ||
90 | afc_excel_path = os.path.join(afc_excel_dir, 'idcard_{0}.xlsx'.format(date_str)) | ||
91 | hil_excel_path = os.path.join(hil_excel_dir, 'idcard_{0}.xlsx'.format(date_str)) | ||
92 | wb_afc.save(afc_excel_path) | 101 | wb_afc.save(afc_excel_path) |
93 | wb_hil.save(hil_excel_path) | 102 | wb_hil.save(hil_excel_path) | ... | ... |
-
Please register or sign in to post a comment