add wechart process
Showing
3 changed files
with
21 additions
and
6 deletions
1 | import copy | 1 | import copy |
2 | import re | ||
2 | 3 | ||
3 | TIME_NUM = 600000000 | 4 | TIME_NUM = 600000000 |
4 | 5 | ||
... | @@ -909,3 +910,5 @@ PATTERN_LIST = ['收入', '存入', '支出', '支取', '金额', '余额', '发 | ... | @@ -909,3 +910,5 @@ PATTERN_LIST = ['收入', '存入', '支出', '支取', '金额', '余额', '发 |
909 | '摘要/附言', '交易发生额', '交易摘要', '借贷发生额(借:-贷:+)', '借贷发生额(借:-贷:+)', '联机余额', '交易金额(元)', | 910 | '摘要/附言', '交易发生额', '交易摘要', '借贷发生额(借:-贷:+)', '借贷发生额(借:-贷:+)', '联机余额', '交易金额(元)', |
910 | '交易金额(元)', '账户余额(元)', '账户余额(元)', '会计日期', '摘要代码', '摘要信息', '日期', '短摘要', '本次余额', | 911 | '交易金额(元)', '账户余额(元)', '账户余额(元)', '会计日期', '摘要代码', '摘要信息', '日期', '短摘要', '本次余额', |
911 | '交易后余额', '交易说明', '帐户余额', '交易日期 记账日期'] | 912 | '交易后余额', '交易说明', '帐户余额', '交易日期 记账日期'] |
913 | |||
914 | CN_RE = re.compile(u'[\u4e00-\u9fa5]') | ... | ... |
... | @@ -8,13 +8,13 @@ class DocHandler: | ... | @@ -8,13 +8,13 @@ class DocHandler: |
8 | @staticmethod | 8 | @staticmethod |
9 | def get_link(doc_id, business_type, file='pdf'): | 9 | def get_link(doc_id, business_type, file='pdf'): |
10 | if file == 'pdf': | 10 | if file == 'pdf': |
11 | return '/data/{1}/{0}/{0}.pdf'.format(doc_id, business_type) | 11 | return '/data/{1}/{0}/{2}/{0}.pdf'.format(doc_id, business_type, consts.TMP_DIR_NAME) |
12 | elif file == 'img': | 12 | elif file == 'img': |
13 | return '/data/{1}/{0}/{0}_img.zip'.format(doc_id, business_type) | 13 | return '/data/{1}/{0}/{2}/{0}_img.zip'.format(doc_id, business_type, consts.TMP_DIR_NAME) |
14 | elif file == 'src_excel': | 14 | elif file == 'src_excel': |
15 | return '/data/{1}/{0}/src.xlsx'.format(doc_id, business_type) | 15 | return '/data/{1}/{0}/{2}/src.xlsx'.format(doc_id, business_type, consts.TMP_DIR_NAME) |
16 | else: | 16 | else: |
17 | return '/data/{1}/{0}/{0}.xlsx'.format(doc_id, business_type) | 17 | return '/data/{1}/{0}/{2}/{0}.xlsx'.format(doc_id, business_type, consts.TMP_DIR_NAME) |
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: | ... | ... |
... | @@ -311,7 +311,17 @@ class BSWorkbook(Workbook): | ... | @@ -311,7 +311,17 @@ class BSWorkbook(Workbook): |
311 | res_str = '{0}.{1}'.format(res_str[:pre_idx], res_str[period_idx + 1:]) | 311 | res_str = '{0}.{1}'.format(res_str[:pre_idx], res_str[period_idx + 1:]) |
312 | return res_str | 312 | return res_str |
313 | 313 | ||
314 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column): | 314 | @staticmethod |
315 | def wechart_func(row_value): | ||
316 | row_value = list(row_value) | ||
317 | if isinstance(row_value[1], str): | ||
318 | cn_chars = re.findall(consts.CN_RE, row_value[1]) | ||
319 | cn_str = ''.join(cn_chars) | ||
320 | row_value[2] = cn_str + row_value[2] | ||
321 | row_value[1] = re.sub(consts.CN_RE, '', row_value[1]) | ||
322 | return row_value | ||
323 | |||
324 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column, classify): | ||
315 | summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY) | 325 | summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY) |
316 | date_cell_idx = statistics_header_info.get(consts.DATE_KEY) | 326 | date_cell_idx = statistics_header_info.get(consts.DATE_KEY) |
317 | amount_cell_idx = statistics_header_info.get(consts.AMOUNT_KEY) # None or src or append | 327 | amount_cell_idx = statistics_header_info.get(consts.AMOUNT_KEY) # None or src or append |
... | @@ -343,6 +353,8 @@ class BSWorkbook(Workbook): | ... | @@ -343,6 +353,8 @@ class BSWorkbook(Workbook): |
343 | ws = self.get_sheet_by_name(part[0]) | 353 | ws = self.get_sheet_by_name(part[0]) |
344 | for row_value in ws.iter_rows(min_row=part[1], max_row=part[2], values_only=True): | 354 | for row_value in ws.iter_rows(min_row=part[1], max_row=part[2], values_only=True): |
345 | if any(row_value): | 355 | if any(row_value): |
356 | if classify == consts.WECHART_CLASSIFY: | ||
357 | row_value = self.wechart_func(row_value) | ||
346 | new_ws.append(row_value) | 358 | new_ws.append(row_value) |
347 | # 3.2.提取信息、高亮 | 359 | # 3.2.提取信息、高亮 |
348 | amount_mapping = {} | 360 | amount_mapping = {} |
... | @@ -506,7 +518,7 @@ class BSWorkbook(Workbook): | ... | @@ -506,7 +518,7 @@ class BSWorkbook(Workbook): |
506 | for month_list in month_mapping.values(): | 518 | for month_list in month_mapping.values(): |
507 | month_list.sort(key=lambda x: x[-1], reverse=is_reverse) | 519 | month_list.sort(key=lambda x: x[-1], reverse=is_reverse) |
508 | 520 | ||
509 | self.build_month_sheet(ms, card, month_mapping, is_reverse, statistics_header_info, max_column) | 521 | self.build_month_sheet(ms, card, month_mapping, is_reverse, statistics_header_info, max_column, classify) |
510 | 522 | ||
511 | # 4.删除原表 | 523 | # 4.删除原表 |
512 | for sheet in sheets_list: | 524 | for sheet in sheets_list: | ... | ... |
-
Please register or sign in to post a comment