fix bug
Showing
3 changed files
with
15 additions
and
7 deletions
... | @@ -18,7 +18,7 @@ class DocHandler: | ... | @@ -18,7 +18,7 @@ class DocHandler: |
18 | 18 | ||
19 | def get_doc_list(self, doc_queryset, business_type): | 19 | def get_doc_list(self, doc_queryset, business_type): |
20 | for doc_dict in doc_queryset: | 20 | for doc_dict in doc_queryset: |
21 | if doc_dict['status'] != DocStatus.COMPLETE.value: | 21 | if doc_dict['status'] not in [DocStatus.COMPLETE.value, DocStatus.UPLOAD_FAILED.value]: |
22 | continue | 22 | continue |
23 | doc_id = doc_dict.get('id') | 23 | doc_id = doc_dict.get('id') |
24 | doc_dict['pdf_link'] = self.get_link(doc_id, business_type) | 24 | doc_dict['pdf_link'] = self.get_link(doc_id, business_type) | ... | ... |
... | @@ -30,7 +30,7 @@ class BSWorkbook(Workbook): | ... | @@ -30,7 +30,7 @@ class BSWorkbook(Workbook): |
30 | self.MAX_MEAN = 31 | 30 | self.MAX_MEAN = 31 |
31 | 31 | ||
32 | @staticmethod | 32 | @staticmethod |
33 | def header_collect(ws, sheet_header_info, header_info): | 33 | def header_collect(ws, sheet_header_info, header_info, max_column_list): |
34 | # sheet_header_info = { | 34 | # sheet_header_info = { |
35 | # 'sheet_name': { | 35 | # 'sheet_name': { |
36 | # 'summary_col': 1, | 36 | # 'summary_col': 1, |
... | @@ -77,6 +77,7 @@ class BSWorkbook(Workbook): | ... | @@ -77,6 +77,7 @@ class BSWorkbook(Workbook): |
77 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COUNT_KEY, find_count) | 77 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COUNT_KEY, find_count) |
78 | min_row = 1 if find_count == 0 else 2 | 78 | min_row = 1 if find_count == 0 else 2 |
79 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.MIN_ROW_KEY, min_row) | 79 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.MIN_ROW_KEY, min_row) |
80 | max_column_list.append(ws.max_column) | ||
80 | 81 | ||
81 | @staticmethod | 82 | @staticmethod |
82 | def header_statistics(sheet_header_info, header_info, classify): | 83 | def header_statistics(sheet_header_info, header_info, classify): |
... | @@ -135,7 +136,7 @@ class BSWorkbook(Workbook): | ... | @@ -135,7 +136,7 @@ class BSWorkbook(Workbook): |
135 | else: | 136 | else: |
136 | fixed_col = consts.CLASSIFY_LIST[classify][1][consts.CLASSIFY_MAP[consts.DATE_KEY]] | 137 | fixed_col = consts.CLASSIFY_LIST[classify][1][consts.CLASSIFY_MAP[consts.DATE_KEY]] |
137 | if fixed_col not in find_col_set and isinstance(fixed_col, int): | 138 | if fixed_col not in find_col_set and isinstance(fixed_col, int): |
138 | date_col = fixed_col | 139 | date_col = fixed_col - 1 |
139 | min_row = sheet_header_info.get(sheet, {}).get(consts.MIN_ROW_KEY, 2) | 140 | min_row = sheet_header_info.get(sheet, {}).get(consts.MIN_ROW_KEY, 2) |
140 | return date_col, min_row | 141 | return date_col, min_row |
141 | 142 | ||
... | @@ -283,7 +284,7 @@ class BSWorkbook(Workbook): | ... | @@ -283,7 +284,7 @@ class BSWorkbook(Workbook): |
283 | res_str = '{0}.{1}'.format(res_str[:period_idx], res_str[period_idx + 1:]) | 284 | res_str = '{0}.{1}'.format(res_str[:period_idx], res_str[period_idx + 1:]) |
284 | return res_str | 285 | return res_str |
285 | 286 | ||
286 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info): | 287 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column): |
287 | summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY) | 288 | summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY) |
288 | date_cell_idx = statistics_header_info.get(consts.DATE_KEY) | 289 | date_cell_idx = statistics_header_info.get(consts.DATE_KEY) |
289 | amount_cell_idx = statistics_header_info.get(consts.AMOUNT_KEY) # None or src or append | 290 | amount_cell_idx = statistics_header_info.get(consts.AMOUNT_KEY) # None or src or append |
... | @@ -292,6 +293,10 @@ class BSWorkbook(Workbook): | ... | @@ -292,6 +293,10 @@ class BSWorkbook(Workbook): |
292 | outlay_cell_idx = statistics_header_info.get(consts.OUTLAY_KEY) | 293 | outlay_cell_idx = statistics_header_info.get(consts.OUTLAY_KEY) |
293 | borrow_cell_idx = statistics_header_info.get(consts.BORROW_KEY) | 294 | borrow_cell_idx = statistics_header_info.get(consts.BORROW_KEY) |
294 | header = list(statistics_header_info.get(consts.HEADER_KEY)) | 295 | header = list(statistics_header_info.get(consts.HEADER_KEY)) |
296 | src_header_len = len(header) | ||
297 | if max_column > src_header_len: | ||
298 | for i in range(max_column - src_header_len): | ||
299 | header.append(None) | ||
295 | 300 | ||
296 | add_col = ['核对结果'] | 301 | add_col = ['核对结果'] |
297 | if amount_cell_idx is None: | 302 | if amount_cell_idx is None: |
... | @@ -431,10 +436,12 @@ class BSWorkbook(Workbook): | ... | @@ -431,10 +436,12 @@ class BSWorkbook(Workbook): |
431 | classify = summary.get('classify', 0) | 436 | classify = summary.get('classify', 0) |
432 | sheet_header_info = {} | 437 | sheet_header_info = {} |
433 | header_info = {} | 438 | header_info = {} |
439 | max_column_list = [] | ||
434 | for sheet in summary.get('sheet', []): | 440 | for sheet in summary.get('sheet', []): |
435 | ws = self.get_sheet_by_name(sheet) | 441 | ws = self.get_sheet_by_name(sheet) |
436 | self.header_collect(ws, sheet_header_info, header_info) | 442 | self.header_collect(ws, sheet_header_info, header_info, max_column_list) |
437 | statistics_header_info = self.header_statistics(sheet_header_info, header_info, classify) | 443 | statistics_header_info = self.header_statistics(sheet_header_info, header_info, classify) |
444 | max_column = max(max_column_list) | ||
438 | 445 | ||
439 | # 1.2.按月份分割 min_row 正文第一行 date_col 日期行 | 446 | # 1.2.按月份分割 min_row 正文第一行 date_col 日期行 |
440 | start_date = summary.get('start_date') | 447 | start_date = summary.get('start_date') |
... | @@ -466,7 +473,7 @@ class BSWorkbook(Workbook): | ... | @@ -466,7 +473,7 @@ class BSWorkbook(Workbook): |
466 | for month_list in month_mapping.values(): | 473 | for month_list in month_mapping.values(): |
467 | month_list.sort(key=lambda x: x[-1], reverse=is_reverse) | 474 | month_list.sort(key=lambda x: x[-1], reverse=is_reverse) |
468 | 475 | ||
469 | self.build_month_sheet(ms, card, month_mapping, is_reverse, statistics_header_info) | 476 | self.build_month_sheet(ms, card, month_mapping, is_reverse, statistics_header_info, max_column) |
470 | 477 | ||
471 | # 4.删除原表 | 478 | # 4.删除原表 |
472 | for sheet in summary.get('sheet'): | 479 | for sheet in summary.get('sheet'): | ... | ... |
-
Please register or sign in to post a comment