add bs verify
Showing
3 changed files
with
44 additions
and
8 deletions
| ... | @@ -1558,7 +1558,7 @@ BL_COMPARE_LOGIC = { | ... | @@ -1558,7 +1558,7 @@ BL_COMPARE_LOGIC = { |
| 1558 | 'registeredCapital': ('注册资本', 'se_rmb_compare', {}, '营业执照注册资本与系统不一致'), | 1558 | 'registeredCapital': ('注册资本', 'se_rmb_compare', {}, '营业执照注册资本与系统不一致'), |
| 1559 | } | 1559 | } |
| 1560 | 1560 | ||
| 1561 | BL_COMPARE_LOGIC = { | 1561 | SME_BL_COMPARE_LOGIC = { |
| 1562 | 'legalRepName': ('经营者姓名', 'se_name_compare', {}, '营业执照法定代表人与系统不一致'), | 1562 | 'legalRepName': ('经营者姓名', 'se_name_compare', {}, '营业执照法定代表人与系统不一致'), |
| 1563 | 'businessLicenseDueDate': ('营业期限', 'se_date_compare', {'ocr_split': True, 'long': True, 'ocr_replace': True, 'today': True}, '公司营业期限疑似过期'), | 1563 | 'businessLicenseDueDate': ('营业期限', 'se_date_compare', {'ocr_split': True, 'long': True, 'ocr_replace': True, 'today': True}, '公司营业期限疑似过期'), |
| 1564 | } | 1564 | } | ... | ... |
| ... | @@ -168,6 +168,12 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -168,6 +168,12 @@ class Command(BaseCommand, LoggerMixin): |
| 168 | words = cell.get('words') | 168 | words = cell.get('words') |
| 169 | ws.cell(row=r1 + 1, column=c1 + 1, value=words) | 169 | ws.cell(row=r1 + 1, column=c1 + 1, value=words) |
| 170 | 170 | ||
| 171 | # 真伪 | ||
| 172 | verify_info = [] | ||
| 173 | verify_dict = sheet.get('verify', {}) | ||
| 174 | if verify_dict.get('verify_res') == 'fake': | ||
| 175 | verify_info.extend(verify_dict.get('verify_info', [])) | ||
| 176 | |||
| 171 | # ['户名', '卡号', '页码', '回单验证码', '打印时间', '起始时间', '终止时间'] | 177 | # ['户名', '卡号', '页码', '回单验证码', '打印时间', '起始时间', '终止时间'] |
| 172 | summary = sheet.get('summary') | 178 | summary = sheet.get('summary') |
| 173 | card = summary[1] | 179 | card = summary[1] |
| ... | @@ -183,6 +189,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -183,6 +189,7 @@ class Command(BaseCommand, LoggerMixin): |
| 183 | pt_list = role_dict.setdefault('print_time', []) | 189 | pt_list = role_dict.setdefault('print_time', []) |
| 184 | sd_list = role_dict.setdefault('start_date', []) | 190 | sd_list = role_dict.setdefault('start_date', []) |
| 185 | ed_list = role_dict.setdefault('end_date', []) | 191 | ed_list = role_dict.setdefault('end_date', []) |
| 192 | verify_list = role_dict.setdefault('verify', []) | ||
| 186 | if summary[3] is not None: | 193 | if summary[3] is not None: |
| 187 | code_list.append((summary[2], summary[3])) | 194 | code_list.append((summary[2], summary[3])) |
| 188 | if summary[4] is not None: | 195 | if summary[4] is not None: |
| ... | @@ -191,6 +198,10 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -191,6 +198,10 @@ class Command(BaseCommand, LoggerMixin): |
| 191 | sd_list.append(summary[5]) | 198 | sd_list.append(summary[5]) |
| 192 | if summary[6] is not None: | 199 | if summary[6] is not None: |
| 193 | ed_list.append(summary[6]) | 200 | ed_list.append(summary[6]) |
| 201 | if len(verify_info) > 0: | ||
| 202 | verify_list.append( | ||
| 203 | (pno, ino, '、'.join(verify_info)) | ||
| 204 | ) | ||
| 194 | else: | 205 | else: |
| 195 | card_dict = bs_summary.setdefault(card, {}) | 206 | card_dict = bs_summary.setdefault(card, {}) |
| 196 | card_dict['count'] = card_dict.get('count', 0) + 1 | 207 | card_dict['count'] = card_dict.get('count', 0) + 1 |
| ... | @@ -203,6 +214,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -203,6 +214,7 @@ class Command(BaseCommand, LoggerMixin): |
| 203 | pt_list = card_dict.setdefault('print_time', []) | 214 | pt_list = card_dict.setdefault('print_time', []) |
| 204 | sd_list = card_dict.setdefault('start_date', []) | 215 | sd_list = card_dict.setdefault('start_date', []) |
| 205 | ed_list = card_dict.setdefault('end_date', []) | 216 | ed_list = card_dict.setdefault('end_date', []) |
| 217 | verify_list = card_dict.setdefault('verify', []) | ||
| 206 | if summary[0] is not None: | 218 | if summary[0] is not None: |
| 207 | role_list.append(summary[0]) | 219 | role_list.append(summary[0]) |
| 208 | role_set.add(summary[0]) | 220 | role_set.add(summary[0]) |
| ... | @@ -214,6 +226,10 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -214,6 +226,10 @@ class Command(BaseCommand, LoggerMixin): |
| 214 | sd_list.append(summary[5]) | 226 | sd_list.append(summary[5]) |
| 215 | if summary[6] is not None: | 227 | if summary[6] is not None: |
| 216 | ed_list.append(summary[6]) | 228 | ed_list.append(summary[6]) |
| 229 | if len(verify_info) > 0: | ||
| 230 | verify_list.append( | ||
| 231 | (pno, ino, '、'.join(verify_info)) | ||
| 232 | ) | ||
| 217 | 233 | ||
| 218 | if cells_exists: | 234 | if cells_exists: |
| 219 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) | 235 | res_list.append((pno, ino, part_idx, consts.RES_SUCCESS)) |
| ... | @@ -833,6 +849,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -833,6 +849,7 @@ class Command(BaseCommand, LoggerMixin): |
| 833 | merged_bs_summary[main_card]['role'].extend(bs_summary[card]['role']) | 849 | merged_bs_summary[main_card]['role'].extend(bs_summary[card]['role']) |
| 834 | merged_bs_summary[main_card]['role_set'].update(bs_summary[card]['role_set']) | 850 | merged_bs_summary[main_card]['role_set'].update(bs_summary[card]['role_set']) |
| 835 | merged_bs_summary[main_card]['code'].extend(bs_summary[card]['code']) | 851 | merged_bs_summary[main_card]['code'].extend(bs_summary[card]['code']) |
| 852 | merged_bs_summary[main_card]['verify'].extend(bs_summary[card]['verify']) | ||
| 836 | merged_bs_summary[main_card]['print_time'].extend(bs_summary[card]['print_time']) | 853 | merged_bs_summary[main_card]['print_time'].extend(bs_summary[card]['print_time']) |
| 837 | merged_bs_summary[main_card]['start_date'].extend(bs_summary[card]['start_date']) | 854 | merged_bs_summary[main_card]['start_date'].extend(bs_summary[card]['start_date']) |
| 838 | merged_bs_summary[main_card]['end_date'].extend(bs_summary[card]['end_date']) | 855 | merged_bs_summary[main_card]['end_date'].extend(bs_summary[card]['end_date']) |
| ... | @@ -882,7 +899,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -882,7 +899,8 @@ class Command(BaseCommand, LoggerMixin): |
| 882 | # 'classify': [], | 899 | # 'classify': [], |
| 883 | # 'confidence': [], | 900 | # 'confidence': [], |
| 884 | # 'role': [], | 901 | # 'role': [], |
| 885 | # 'code': [('page', 'code')], | 902 | # 'code': [('page', 'code'), ], |
| 903 | # 'verify': [(pno, ino, reason_str), ] | ||
| 886 | # 'print_time': [], | 904 | # 'print_time': [], |
| 887 | # 'start_date': [], | 905 | # 'start_date': [], |
| 888 | # 'end_date': [], | 906 | # 'end_date': [], |
| ... | @@ -896,7 +914,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -896,7 +914,8 @@ class Command(BaseCommand, LoggerMixin): |
| 896 | # 'classify': 0, | 914 | # 'classify': 0, |
| 897 | # 'confidence': [], | 915 | # 'confidence': [], |
| 898 | # 'role': '户名', | 916 | # 'role': '户名', |
| 899 | # 'code': [('page', 'code')], | 917 | # 'code': [('page', 'code'), ], |
| 918 | # 'verify': [(pno, ino, reason_str), ] | ||
| 900 | # 'print_time': [], | 919 | # 'print_time': [], |
| 901 | # 'start_date': [], | 920 | # 'start_date': [], |
| 902 | # 'end_date': [], | 921 | # 'end_date': [], |
| ... | @@ -921,6 +940,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -921,6 +940,7 @@ class Command(BaseCommand, LoggerMixin): |
| 921 | # summary_dict['confidence'].extend(summary['confidence']) | 940 | # summary_dict['confidence'].extend(summary['confidence']) |
| 922 | summary_dict['role'] = summary['role'] | 941 | summary_dict['role'] = summary['role'] |
| 923 | summary_dict['code'].extend(summary['code']) | 942 | summary_dict['code'].extend(summary['code']) |
| 943 | summary_dict['verify'].extend(summary['verify']) | ||
| 924 | summary_dict['print_time'].extend(summary['print_time']) | 944 | summary_dict['print_time'].extend(summary['print_time']) |
| 925 | summary_dict['start_date'].extend(summary['start_date']) | 945 | summary_dict['start_date'].extend(summary['start_date']) |
| 926 | summary_dict['end_date'].extend(summary['end_date']) | 946 | summary_dict['end_date'].extend(summary['end_date']) |
| ... | @@ -952,6 +972,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -952,6 +972,7 @@ class Command(BaseCommand, LoggerMixin): |
| 952 | # card_summary['confidence'].extend(summary['confidence']) | 972 | # card_summary['confidence'].extend(summary['confidence']) |
| 953 | card_summary['sheet'].extend(summary['sheet']) | 973 | card_summary['sheet'].extend(summary['sheet']) |
| 954 | card_summary['code'].extend(summary['code']) | 974 | card_summary['code'].extend(summary['code']) |
| 975 | card_summary['verify'].extend(summary['verify']) | ||
| 955 | card_summary['print_time'].extend(summary['print_time']) | 976 | card_summary['print_time'].extend(summary['print_time']) |
| 956 | card_summary['start_date'].extend(summary['start_date']) | 977 | card_summary['start_date'].extend(summary['start_date']) |
| 957 | card_summary['end_date'].extend(summary['end_date']) | 978 | card_summary['end_date'].extend(summary['end_date']) | ... | ... |
| ... | @@ -20,6 +20,7 @@ class BSWorkbook(Workbook): | ... | @@ -20,6 +20,7 @@ class BSWorkbook(Workbook): |
| 20 | self.meta_sheet_title = 'Key info' | 20 | self.meta_sheet_title = 'Key info' |
| 21 | self.blank_row = (None,) | 21 | self.blank_row = (None,) |
| 22 | self.code_header = ('页数', '电子回单验证码') | 22 | self.code_header = ('页数', '电子回单验证码') |
| 23 | self.verify_header = ('页数', '图片序号', '检测内容') | ||
| 23 | self.date_header = ('打印时间', '起始日期', '终止日期', '流水区间结果') | 24 | self.date_header = ('打印时间', '起始日期', '终止日期', '流水区间结果') |
| 24 | self.interest_keyword_header = ('结息关键词', '记账日期', '金额') | 25 | self.interest_keyword_header = ('结息关键词', '记账日期', '金额') |
| 25 | self.salary_keyword_header = ('收入关键词', '记账日期', '金额') | 26 | self.salary_keyword_header = ('收入关键词', '记账日期', '金额') |
| ... | @@ -310,19 +311,28 @@ class BSWorkbook(Workbook): | ... | @@ -310,19 +311,28 @@ class BSWorkbook(Workbook): |
| 310 | month_mapping.setdefault(item, []).append( | 311 | month_mapping.setdefault(item, []).append( |
| 311 | (ws.title, idx_list[i] + min_row, idx_list[i + 1] + min_row - 1, day_mean)) | 312 | (ws.title, idx_list[i] + min_row, idx_list[i + 1] + min_row - 1, day_mean)) |
| 312 | 313 | ||
| 313 | def build_metadata_rows(self, confidence, code, print_time, start_date, end_date, res_count_tuple): | 314 | def build_metadata_rows(self, confidence, code, verify_list, print_time, start_date, end_date, res_count_tuple): |
| 314 | if start_date is None or end_date is None: | 315 | if start_date is None or end_date is None: |
| 315 | timedelta = None | 316 | timedelta = None |
| 316 | else: | 317 | else: |
| 317 | timedelta = (end_date - start_date).days | 318 | timedelta = (end_date - start_date).days |
| 319 | verify_res = '正常' | ||
| 320 | if len(verify_list) > 0: | ||
| 321 | verify_res = '疑似伪造' | ||
| 318 | metadata_rows = [ | 322 | metadata_rows = [ |
| 319 | ('流水识别置信度', confidence), | 323 | ('流水识别置信度', confidence), |
| 324 | ('流水检测结果', verify_res), | ||
| 320 | ('图片总数', res_count_tuple[0]), | 325 | ('图片总数', res_count_tuple[0]), |
| 321 | ('识别成功', res_count_tuple[1]), | 326 | ('识别成功', res_count_tuple[1]), |
| 322 | self.blank_row, | 327 | self.blank_row, |
| 323 | self.code_header, | 328 | self.code_header, |
| 324 | ] | 329 | ] |
| 325 | metadata_rows.extend(code) | 330 | metadata_rows.extend(code) |
| 331 | |||
| 332 | if len(verify_list) > 0: | ||
| 333 | metadata_rows.append(self.verify_header) | ||
| 334 | metadata_rows.extend(verify_list) | ||
| 335 | |||
| 326 | metadata_rows.extend( | 336 | metadata_rows.extend( |
| 327 | [self.blank_row, | 337 | [self.blank_row, |
| 328 | self.date_header, | 338 | self.date_header, |
| ... | @@ -332,18 +342,21 @@ class BSWorkbook(Workbook): | ... | @@ -332,18 +342,21 @@ class BSWorkbook(Workbook): |
| 332 | ) | 342 | ) |
| 333 | return metadata_rows | 343 | return metadata_rows |
| 334 | 344 | ||
| 335 | def build_meta_sheet(self, role_name, card, confidence, code, print_time, start_date, end_date, res_count_tuple): | 345 | def build_meta_sheet(self, role_name, card, confidence, code, verify_list, print_time, start_date, end_date, res_count_tuple): |
| 336 | metadata_rows = self.build_metadata_rows(confidence, code, print_time, start_date, end_date, res_count_tuple) | 346 | metadata_rows = self.build_metadata_rows(confidence, code, verify_list, print_time, start_date, end_date, res_count_tuple) |
| 337 | if not isinstance(role_name, str): | 347 | if not isinstance(role_name, str): |
| 338 | role_name = consts.UNKNOWN_ROLE | 348 | role_name = consts.UNKNOWN_ROLE |
| 339 | ms = self.create_sheet('{0}{1}({2})'.format(self.meta_sheet_title, role_name, card)) | 349 | ms = self.create_sheet('{0}{1}({2})'.format(self.meta_sheet_title, role_name, card)) |
| 340 | for row in metadata_rows: | 350 | for row in metadata_rows: |
| 341 | ms.append(row) | 351 | ms.append(row) |
| 342 | if res_count_tuple[0] != res_count_tuple[1]: | 352 | if len(verify_list) > 0: |
| 343 | for cell in ms[2]: | 353 | for cell in ms[2]: |
| 344 | cell.fill = self.amount_fill | 354 | cell.fill = self.amount_fill |
| 355 | if res_count_tuple[0] != res_count_tuple[1]: | ||
| 345 | for cell in ms[3]: | 356 | for cell in ms[3]: |
| 346 | cell.fill = self.amount_fill | 357 | cell.fill = self.amount_fill |
| 358 | for cell in ms[4]: | ||
| 359 | cell.fill = self.amount_fill | ||
| 347 | return ms | 360 | return ms |
| 348 | 361 | ||
| 349 | @staticmethod | 362 | @staticmethod |
| ... | @@ -608,7 +621,8 @@ class BSWorkbook(Workbook): | ... | @@ -608,7 +621,8 @@ class BSWorkbook(Workbook): |
| 608 | # 'classify': 0, | 621 | # 'classify': 0, |
| 609 | # 'confidence': 0.9, | 622 | # 'confidence': 0.9, |
| 610 | # 'role': '柳雪', | 623 | # 'role': '柳雪', |
| 611 | # 'code': [('page', 'code')], | 624 | # 'code': [('page', 'code'), ], |
| 625 | # 'verify': [(pno, ino, reason_str), ] | ||
| 612 | # 'print_time': 'datetime', | 626 | # 'print_time': 'datetime', |
| 613 | # 'start_date': 'datetime', | 627 | # 'start_date': 'datetime', |
| 614 | # 'end_date': 'datetime', | 628 | # 'end_date': 'datetime', |
| ... | @@ -661,6 +675,7 @@ class BSWorkbook(Workbook): | ... | @@ -661,6 +675,7 @@ class BSWorkbook(Workbook): |
| 661 | new_card, | 675 | new_card, |
| 662 | confidence, | 676 | confidence, |
| 663 | summary.get('code'), | 677 | summary.get('code'), |
| 678 | summary.get('verify'), | ||
| 664 | summary.get('print_time'), | 679 | summary.get('print_time'), |
| 665 | start_date, | 680 | start_date, |
| 666 | end_date, | 681 | end_date, | ... | ... |
-
Please register or sign in to post a comment