add:log
Showing
3 changed files
with
26 additions
and
4 deletions
src-0424.zip
0 → 100644
No preview for this file type
... | @@ -178,6 +178,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -178,6 +178,8 @@ class Command(BaseCommand, LoggerMixin): |
178 | # self.online_log.info('{0} [edms download success] [pdf_path={1}]'.format(self.log_base, pdf_path)) | 178 | # self.online_log.info('{0} [edms download success] [pdf_path={1}]'.format(self.log_base, pdf_path)) |
179 | 179 | ||
180 | def bs_process(self, wb, ocr_data, bs_summary, unknown_summary, classify, res_list, pno, ino, part_idx, income_keywords_dictionary): | 180 | def bs_process(self, wb, ocr_data, bs_summary, unknown_summary, classify, res_list, pno, ino, part_idx, income_keywords_dictionary): |
181 | self.online_log.warn('{0} [bs_process] [ocr_data={1}] [bs_summary={2}] [unknown_summary={3}] [classify={4}] [res_list={5}] [pno={6}] [ino={7}] [part_idx={8}] [income_keywords_dictionary={9}]'.format( | ||
182 | self.log_base, ocr_data, bs_summary, unknown_summary, classify, res_list, pno, ino, part_idx, income_keywords_dictionary)) | ||
181 | sheets = ocr_data.get('data', []) | 183 | sheets = ocr_data.get('data', []) |
182 | if not sheets: | 184 | if not sheets: |
183 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_EMPTY)) | 185 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_EMPTY)) |
... | @@ -2053,8 +2055,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2053,8 +2055,8 @@ class Command(BaseCommand, LoggerMixin): |
2053 | 2055 | ||
2054 | try: | 2056 | try: |
2055 | # 重构Excel文件 | 2057 | # 重构Excel文件 |
2056 | # src_excel_path = os.path.join(doc_data_path, 'src.xlsx') | 2058 | src_excel_path = os.path.join(doc_data_path, 'src.xlsx') |
2057 | # wb.save(src_excel_path) | 2059 | wb.save(src_excel_path) |
2058 | #need_follow表示在上传edms时文件名是否要添加"关注"两字 | 2060 | #need_follow表示在上传edms时文件名是否要添加"关注"两字 |
2059 | count_list, need_follow = wb.rebuild(merged_bs_summary, license_summary, res_list, doc.document_scheme, contract_result, doc.metadata, financial_statement_dict, financial_explanation_dict, down_payment_dict) | 2061 | count_list, need_follow = wb.rebuild(merged_bs_summary, license_summary, res_list, doc.document_scheme, contract_result, doc.metadata, financial_statement_dict, financial_explanation_dict, down_payment_dict) |
2060 | wb.save(excel_path) | 2062 | wb.save(excel_path) | ... | ... |
... | @@ -122,13 +122,19 @@ class BSWorkbook(Workbook, LoggerMixin): | ... | @@ -122,13 +122,19 @@ class BSWorkbook(Workbook, LoggerMixin): |
122 | header_col_list = [] | 122 | header_col_list = [] |
123 | for first_row in ws.iter_rows(max_row=1, min_row=1, values_only=True): | 123 | for first_row in ws.iter_rows(max_row=1, min_row=1, values_only=True): |
124 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.HEADER_KEY, first_row) | 124 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.HEADER_KEY, first_row) |
125 | self.online_log.warn('{0} [header_collect_1] [first_row={1}] [sheet_header_info={2}]'.format( | ||
126 | self.log_base, first_row, sheet_header_info)) | ||
125 | for idx, header_value in enumerate(first_row): | 127 | for idx, header_value in enumerate(first_row): |
126 | header_col = self.get_header_col(header_value, classify) | 128 | header_col = self.get_header_col(header_value, classify) |
129 | self.online_log.warn('{0} [header_collect_2] [idx={1}] [header_value={2}] [header_col={3}]'.format( | ||
130 | self.log_base, idx, header_value, header_col)) | ||
127 | if classify == consts.MS_CLASSIFY and header_col == consts.OVER_KEY and \ | 131 | if classify == consts.MS_CLASSIFY and header_col == consts.OVER_KEY and \ |
128 | header_value == '账户余额现转标志' and not first_row[idx - 1]: | 132 | header_value == '账户余额现转标志' and not first_row[idx - 1]: |
129 | idx -= 1 | 133 | idx -= 1 |
130 | if header_col is not None: | 134 | if header_col is not None: |
131 | header_col_list.append((idx, header_col)) | 135 | header_col_list.append((idx, header_col)) |
136 | self.online_log.warn('{0} [header_collect_3] [header_col_list={1}]'.format( | ||
137 | self.log_base, header_col_list)) | ||
132 | 138 | ||
133 | find_count = len(header_col_list) | 139 | find_count = len(header_col_list) |
134 | if find_count < 2: | 140 | if find_count < 2: |
... | @@ -136,15 +142,25 @@ class BSWorkbook(Workbook, LoggerMixin): | ... | @@ -136,15 +142,25 @@ class BSWorkbook(Workbook, LoggerMixin): |
136 | else: | 142 | else: |
137 | for idx, header_col in header_col_list: | 143 | for idx, header_col in header_col_list: |
138 | sheet_header_info.setdefault(ws.title, {}).setdefault(header_col, idx) | 144 | sheet_header_info.setdefault(ws.title, {}).setdefault(header_col, idx) |
145 | self.online_log.warn('{0} [header_collect_4] [sheet_header_info={1}]'.format( | ||
146 | self.log_base, sheet_header_info)) | ||
139 | find_col_set = sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COL_KEY, set()) | 147 | find_col_set = sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COL_KEY, set()) |
140 | find_col_set.add(idx) | 148 | find_col_set.add(idx) |
149 | self.online_log.warn('{0} [header_collect_5] [sheet_header_info={1}]'.format( | ||
150 | self.log_base, sheet_header_info)) | ||
141 | col_count = header_info.setdefault(header_col, {}).get(idx) | 151 | col_count = header_info.setdefault(header_col, {}).get(idx) |
142 | header_info.setdefault(header_col, {})[idx] = 1 if col_count is None else col_count+1 | 152 | header_info.setdefault(header_col, {})[idx] = 1 if col_count is None else col_count+1 |
153 | self.online_log.warn('{0} [header_collect_6] [header_info={1}]'.format( | ||
154 | self.log_base, header_info)) | ||
143 | 155 | ||
144 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COUNT_KEY, find_count) | 156 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.FIND_COUNT_KEY, find_count) |
157 | self.online_log.warn('{0} [header_collect_7] [sheet_header_info={1}]'.format( | ||
158 | self.log_base, sheet_header_info)) | ||
145 | min_row = 1 if find_count == 0 else 2 | 159 | min_row = 1 if find_count == 0 else 2 |
146 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.MIN_ROW_KEY, min_row) | 160 | sheet_header_info.setdefault(ws.title, {}).setdefault(consts.MIN_ROW_KEY, min_row) |
147 | max_column_list.append(ws.max_column) | 161 | max_column_list.append(ws.max_column) |
162 | self.online_log.warn('{0} [header_collect_8] [sheet_header_info={1}] [header_info={2}] [max_column_list={3}]'.format( | ||
163 | self.log_base, sheet_header_info, header_info, max_column_list)) | ||
148 | 164 | ||
149 | @staticmethod | 165 | @staticmethod |
150 | def header_statistics(sheet_header_info, header_info, classify, special_nhzs): | 166 | def header_statistics(sheet_header_info, header_info, classify, special_nhzs): |
... | @@ -194,7 +210,7 @@ class BSWorkbook(Workbook, LoggerMixin): | ... | @@ -194,7 +210,7 @@ class BSWorkbook(Workbook, LoggerMixin): |
194 | return statistics_header_info, max_find_count | 210 | return statistics_header_info, max_find_count |
195 | 211 | ||
196 | @staticmethod | 212 | @staticmethod |
197 | def get_data_col_min_row(sheet, sheet_header_info, header_info, classify): | 213 | def get_data_col_min_row(self, sheet, sheet_header_info, header_info, classify): |
198 | date_col = sheet_header_info.get(sheet, {}).get(consts.DATE_KEY) | 214 | date_col = sheet_header_info.get(sheet, {}).get(consts.DATE_KEY) |
199 | if date_col is None: | 215 | if date_col is None: |
200 | date_col_dict = header_info.get(consts.DATE_KEY, {}) | 216 | date_col_dict = header_info.get(consts.DATE_KEY, {}) |
... | @@ -273,6 +289,8 @@ class BSWorkbook(Workbook, LoggerMixin): | ... | @@ -273,6 +289,8 @@ class BSWorkbook(Workbook, LoggerMixin): |
273 | return reverse_trend | 289 | return reverse_trend |
274 | 290 | ||
275 | def sheet_split(self, ws, date_col, min_row, month_mapping, reverse_trend_list, date_list, date_statistics): | 291 | def sheet_split(self, ws, date_col, min_row, month_mapping, reverse_trend_list, date_list, date_statistics): |
292 | self.online_log.warn('{0} [sheet_split] [date_col={1}] [min_row={2}] [month_mapping={3}] [reverse_trend_list={4}] [date_list={5}] [date_statistics={6}]'.format( | ||
293 | self.log_base, date_col, min_row, month_mapping, reverse_trend_list, date_list, date_statistics)) | ||
276 | if date_col is None: | 294 | if date_col is None: |
277 | # month_info process | 295 | # month_info process |
278 | month_info = month_mapping.setdefault('xxxx-xx', []) | 296 | month_info = month_mapping.setdefault('xxxx-xx', []) |
... | @@ -749,7 +767,9 @@ class BSWorkbook(Workbook, LoggerMixin): | ... | @@ -749,7 +767,9 @@ class BSWorkbook(Workbook, LoggerMixin): |
749 | reverse_trend_list = [] # 用于判断倒序与正序 | 767 | reverse_trend_list = [] # 用于判断倒序与正序 |
750 | for sheet in sheets_list: | 768 | for sheet in sheets_list: |
751 | ws = self.get_sheet_by_name(sheet) | 769 | ws = self.get_sheet_by_name(sheet) |
752 | date_col, min_row = self.get_data_col_min_row(sheet, sheet_header_info, header_info, classify) | 770 | date_col, min_row = self.get_data_col_min_row(self, sheet, sheet_header_info, header_info, classify) |
771 | self.online_log.warn('{0} [bs_rebuild] [date_col={1}] [min_row={2}]'.format( | ||
772 | self.log_base, date_col, min_row)) | ||
753 | self.sheet_split(ws, date_col, min_row, month_mapping, reverse_trend_list, date_list, date_statistics) | 773 | self.sheet_split(ws, date_col, min_row, month_mapping, reverse_trend_list, date_list, date_statistics) |
754 | 774 | ||
755 | if date_statistics is True and len(date_list) > 1: | 775 | if date_statistics is True and len(date_list) > 1: | ... | ... |
-
Please register or sign in to post a comment