update bs report
Showing
5 changed files
with
88 additions
and
23 deletions
... | @@ -23,7 +23,7 @@ from common.electronic_hil_contract.hil_contract_ocr import predict as hil_predi | ... | @@ -23,7 +23,7 @@ from common.electronic_hil_contract.hil_contract_ocr import predict as hil_predi |
23 | from apps.doc import consts | 23 | from apps.doc import consts |
24 | # from apps.doc.ocr.edms import EDMS, rh | 24 | # from apps.doc.ocr.edms import EDMS, rh |
25 | from apps.doc.ocr.ecm import ECM, rh | 25 | from apps.doc.ocr.ecm import ECM, rh |
26 | from apps.doc.named_enum import KeywordsType, FailureReason, WorkflowName, ProcessName, RequestTeam, RequestTrigger | 26 | from apps.doc.named_enum import KeywordsType, FailureReason, WorkflowName, ProcessName, RequestTeam, RequestTrigger, BSCheckResult |
27 | from apps.doc.exceptions import EDMSException, OCR1Exception, OCR2Exception, OCR4Exception | 27 | from apps.doc.exceptions import EDMSException, OCR1Exception, OCR2Exception, OCR4Exception |
28 | from apps.doc.ocr.wb import BSWorkbook | 28 | from apps.doc.ocr.wb import BSWorkbook |
29 | from apps.doc.models import ( | 29 | from apps.doc.models import ( |
... | @@ -944,7 +944,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -944,7 +944,7 @@ class Command(BaseCommand, LoggerMixin): |
944 | 'role': bs_info.get('role', ''), | 944 | 'role': bs_info.get('role', ''), |
945 | 'print_time': print_date, | 945 | 'print_time': print_date, |
946 | 'timedelta': bs_info.get('timedelta', ''), | 946 | 'timedelta': bs_info.get('timedelta', ''), |
947 | 'verify': bs_info.get('verify', True) | 947 | 'verify': bs_info.get('verify_res_ebank', True) |
948 | } | 948 | } |
949 | ) | 949 | ) |
950 | return res | 950 | return res |
... | @@ -1626,7 +1626,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1626,7 +1626,7 @@ class Command(BaseCommand, LoggerMixin): |
1626 | # 'idcard': True or False, | 1626 | # 'idcard': True or False, |
1627 | # 'bs': None or normal or mobile, | 1627 | # 'bs': None or normal or mobile, |
1628 | # } | 1628 | # } |
1629 | report_list = [None, False, None, None] | 1629 | report_list = [None, False, None, None, None, None] |
1630 | do_dda = is_hil and doc.document_scheme == consts.DOC_SCHEME_LIST[1] | 1630 | do_dda = is_hil and doc.document_scheme == consts.DOC_SCHEME_LIST[1] |
1631 | except Exception as e: | 1631 | except Exception as e: |
1632 | self.online_log.error('{0} [process error (db filter)] [task={1}] [error={2}]'.format( | 1632 | self.online_log.error('{0} [process error (db filter)] [task={1}] [error={2}]'.format( |
... | @@ -1815,6 +1815,15 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1815,6 +1815,15 @@ class Command(BaseCommand, LoggerMixin): |
1815 | else: | 1815 | else: |
1816 | report_list[2] = WorkflowName.NORMAL.value | 1816 | report_list[2] = WorkflowName.NORMAL.value |
1817 | 1817 | ||
1818 | bs_name_list = [] | ||
1819 | for tmp_classify in bs_classify_set: | ||
1820 | try: | ||
1821 | bs_name = consts.CLASSIFY_LIST[tmp_classify][0] | ||
1822 | except Exception as e: | ||
1823 | bs_name = 'Unknown' | ||
1824 | bs_name_list.append(bs_name) | ||
1825 | report_list[4] = '、'.join(bs_name_list) | ||
1826 | |||
1818 | merged_bs_summary = self.rebuild_bs_summary(bs_summary, unknown_summary) | 1827 | merged_bs_summary = self.rebuild_bs_summary(bs_summary, unknown_summary) |
1819 | del unknown_summary | 1828 | del unknown_summary |
1820 | 1829 | ||
... | @@ -1901,6 +1910,40 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1901,6 +1910,40 @@ class Command(BaseCommand, LoggerMixin): |
1901 | else: | 1910 | else: |
1902 | self.online_log.info('{0} [process complete] [task={1}]'.format(self.log_base, task_str)) | 1911 | self.online_log.info('{0} [process complete] [task={1}]'.format(self.log_base, task_str)) |
1903 | os.remove(excel_path) | 1912 | os.remove(excel_path) |
1913 | |||
1914 | # report新增流水真伪 | ||
1915 | try: | ||
1916 | check_false_classify = set() | ||
1917 | all_check_classify = set() | ||
1918 | if isinstance(doc.metadata, str): | ||
1919 | verify_field = 'verify_res_ebank' | ||
1920 | else: | ||
1921 | verify_field = 'verify_res_paper_bank' | ||
1922 | for bs_info in merged_bs_summary.values(): | ||
1923 | all_check_classify.add(bs_info['classify']) | ||
1924 | if verify_field not in bs_info: | ||
1925 | report_list[5] = BSCheckResult.CHECK_FAILED.value | ||
1926 | break | ||
1927 | if not bs_info[verify_field]: | ||
1928 | check_false_classify.add(bs_info['classify']) | ||
1929 | else: | ||
1930 | # 电子 | ||
1931 | if isinstance(doc.metadata, str): | ||
1932 | if len(check_false_classify) > 0: | ||
1933 | report_list[5] = BSCheckResult.CHECK_FALSE.value | ||
1934 | else: | ||
1935 | report_list[5] = BSCheckResult.CHECK_TRUE.value | ||
1936 | # 纸质 | ||
1937 | else: | ||
1938 | if check_false_classify & consts.BS_VERIFY_CLASSIFY: | ||
1939 | report_list[5] = BSCheckResult.CHECK_FALSE.value | ||
1940 | elif all_check_classify & consts.BS_VERIFY_CLASSIFY: | ||
1941 | report_list[5] = BSCheckResult.CHECK_TRUE.value | ||
1942 | else: | ||
1943 | report_list[5] = BSCheckResult.NO_CHECK.value | ||
1944 | except Exception as e: | ||
1945 | report_list[5] = BSCheckResult.CHECK_FAILED.value | ||
1946 | |||
1904 | finally: | 1947 | finally: |
1905 | self.rebuild_contract(license_summary, contract_result_compare) | 1948 | self.rebuild_contract(license_summary, contract_result_compare) |
1906 | 1949 | ||
... | @@ -2222,6 +2265,9 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2222,6 +2265,9 @@ class Command(BaseCommand, LoggerMixin): |
2222 | 2265 | ||
2223 | try: | 2266 | try: |
2224 | if report_list[2] is not None: | 2267 | if report_list[2] is not None: |
2268 | is_ebank = True if isinstance(doc.metadata, str) else False | ||
2269 | bank_name = report_list[4] if isinstance(report_list[4], str) else 'Unknown' | ||
2270 | bs_check_result = report_list[5] if isinstance(report_list[5], int) else BSCheckResult.CHECK_FAILED.value | ||
2225 | report_table.objects.create( | 2271 | report_table.objects.create( |
2226 | case_number=doc.application_id, | 2272 | case_number=doc.application_id, |
2227 | request_team=RequestTeam.get_value(doc.document_scheme, 0), | 2273 | request_team=RequestTeam.get_value(doc.document_scheme, 0), |
... | @@ -2231,6 +2277,9 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -2231,6 +2277,9 @@ class Command(BaseCommand, LoggerMixin): |
2231 | transaction_end=end_time, | 2277 | transaction_end=end_time, |
2232 | process_name=ProcessName.BS.value, | 2278 | process_name=ProcessName.BS.value, |
2233 | workflow_name=report_list[2], | 2279 | workflow_name=report_list[2], |
2280 | bank_name=bank_name, | ||
2281 | is_ebank=is_ebank, | ||
2282 | bs_check_result=bs_check_result, | ||
2234 | ) | 2283 | ) |
2235 | except Exception as e: | 2284 | except Exception as e: |
2236 | self.online_log.error('{0} [process error (report db save)] [error={1}]'.format( | 2285 | self.online_log.error('{0} [process error (report db save)] [error={1}]'.format( | ... | ... |
... | @@ -455,12 +455,9 @@ class HILOCRReport(models.Model): | ... | @@ -455,12 +455,9 @@ class HILOCRReport(models.Model): |
455 | workflow_name = models.SmallIntegerField(null=True, verbose_name="工作流程") | 455 | workflow_name = models.SmallIntegerField(null=True, verbose_name="工作流程") |
456 | notes = models.CharField(null=True, max_length=2048, verbose_name="备注") | 456 | notes = models.CharField(null=True, max_length=2048, verbose_name="备注") |
457 | 457 | ||
458 | # 1. bank_name string eg. '农业银行-交易清单' | 458 | bank_name = models.CharField(null=True, max_length=2048, verbose_name="版式名称") |
459 | # 2. is_ebank boolean eg. 1 | 459 | is_ebank = models.BooleanField(default=False, verbose_name="是否电子") |
460 | 460 | bs_check_result = models.SmallIntegerField(default=0, verbose_name="鉴伪结果") # 0 无鉴伪 1鉴伪pass 2鉴伪nopass 3鉴伪过程异常 | |
461 | # 1. is_bs_check boolean eg. 1 | ||
462 | # 2. bs_check_result int eg. 2(电子-author) | ||
463 | # | ||
464 | 461 | ||
465 | class Meta: | 462 | class Meta: |
466 | managed = False | 463 | managed = False |
... | @@ -482,6 +479,10 @@ class AFCOCRReport(models.Model): | ... | @@ -482,6 +479,10 @@ class AFCOCRReport(models.Model): |
482 | workflow_name = models.SmallIntegerField(null=True, verbose_name="工作流程") | 479 | workflow_name = models.SmallIntegerField(null=True, verbose_name="工作流程") |
483 | notes = models.CharField(null=True, max_length=2048, verbose_name="备注") | 480 | notes = models.CharField(null=True, max_length=2048, verbose_name="备注") |
484 | 481 | ||
482 | bank_name = models.CharField(null=True, max_length=2048, verbose_name="版式名称") | ||
483 | is_ebank = models.BooleanField(default=False, verbose_name="是否电子") | ||
484 | bs_check_result = models.SmallIntegerField(default=0, verbose_name="鉴伪结果") # 0 无鉴伪 1鉴伪pass 2鉴伪nopass | ||
485 | |||
485 | class Meta: | 486 | class Meta: |
486 | managed = False | 487 | managed = False |
487 | db_table = 'afc_ocr_report' | 488 | db_table = 'afc_ocr_report' | ... | ... |
... | @@ -83,3 +83,10 @@ class RPAResult(NamedEnum): | ... | @@ -83,3 +83,10 @@ class RPAResult(NamedEnum): |
83 | ERROR1 = (2, 'business error') | 83 | ERROR1 = (2, 'business error') |
84 | ERROR2 = (3, 'system error') | 84 | ERROR2 = (3, 'system error') |
85 | NULL = (0, 'null') | 85 | NULL = (0, 'null') |
86 | |||
87 | |||
88 | class BSCheckResult(NamedEnum): | ||
89 | NO_CHECK = (0, 'NO_CHECK') | ||
90 | CHECK_TRUE = (1, 'CHECK_TRUE') | ||
91 | CHECK_FALSE = (2, 'CHECK_FALSE') | ||
92 | CHECK_FAILED = (3, 'CHECK_FAILED') | ... | ... |
... | @@ -394,8 +394,9 @@ class BSWorkbook(Workbook): | ... | @@ -394,8 +394,9 @@ class BSWorkbook(Workbook): |
394 | cell.fill = self.amount_fill | 394 | cell.fill = self.amount_fill |
395 | 395 | ||
396 | # verify_res = False if len(metadata_highlight_row) > 0 or len(verify_highlight_row) > 0 else True | 396 | # verify_res = False if len(metadata_highlight_row) > 0 or len(verify_highlight_row) > 0 else True |
397 | verify_res = False if len(metadata_highlight_row) > 0 else True | 397 | verify_res_ebank = False if len(metadata_highlight_row) > 0 else True |
398 | return ms, timedelta, verify_res | 398 | verify_res_paper_bank = False if len(verify_highlight_row) > 0 else True |
399 | return ms, timedelta, verify_res_ebank, verify_res_paper_bank | ||
399 | 400 | ||
400 | @staticmethod | 401 | @staticmethod |
401 | def amount_format(amount_str): | 402 | def amount_format(amount_str): |
... | @@ -726,7 +727,7 @@ class BSWorkbook(Workbook): | ... | @@ -726,7 +727,7 @@ class BSWorkbook(Workbook): |
726 | # 2.元信息提取表 | 727 | # 2.元信息提取表 |
727 | confidence = self.get_confidence(max_find_count, classify) | 728 | confidence = self.get_confidence(max_find_count, classify) |
728 | is_verify_classify = classify in consts.BS_VERIFY_CLASSIFY | 729 | is_verify_classify = classify in consts.BS_VERIFY_CLASSIFY |
729 | ms, timedelta, verify_res = self.build_meta_sheet(role_name, | 730 | ms, timedelta, verify_res_ebank, verify_res_paper_bank = self.build_meta_sheet(role_name, |
730 | new_card, | 731 | new_card, |
731 | confidence, | 732 | confidence, |
732 | summary.get('code'), | 733 | summary.get('code'), |
... | @@ -740,7 +741,8 @@ class BSWorkbook(Workbook): | ... | @@ -740,7 +741,8 @@ class BSWorkbook(Workbook): |
740 | 741 | ||
741 | summary['timedelta'] = timedelta | 742 | summary['timedelta'] = timedelta |
742 | summary['end_date'] = end_date | 743 | summary['end_date'] = end_date |
743 | summary['verify'] = verify_res | 744 | summary['verify_res_ebank'] = verify_res_ebank |
745 | summary['verify_res_paper_bank'] = verify_res_paper_bank | ||
744 | 746 | ||
745 | # 3.创建月份表、提取/高亮关键行 | 747 | # 3.创建月份表、提取/高亮关键行 |
746 | # 倒序处理 | 748 | # 倒序处理 | ... | ... |
... | @@ -10,11 +10,17 @@ hil_sql = """ | ... | @@ -10,11 +10,17 @@ hil_sql = """ |
10 | duration smallint, | 10 | duration smallint, |
11 | create_time datetime not null | 11 | create_time datetime not null |
12 | ); | 12 | ); |
13 | |||
14 | ALTER TABLE hil_ocr_report ADD bank_name nvarchar(2048); | ||
15 | ALTER TABLE hil_ocr_report ADD is_ebank bit default 0 not null; | ||
16 | ALTER TABLE hil_ocr_report ADD bs_check_result tinyint default 0 not null; | ||
13 | """ | 17 | """ |
14 | 18 | ||
15 | # afc_sql = """ | 19 | afc_sql = """ |
16 | # | 20 | ALTER TABLE afc_ocr_report ADD bank_name nvarchar(2048); |
17 | # """ | 21 | ALTER TABLE afc_ocr_report ADD is_ebank bit default 0 not null; |
22 | ALTER TABLE afc_ocr_report ADD bs_check_result tinyint default 0 not null; | ||
23 | """ | ||
18 | 24 | ||
19 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | 25 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) |
20 | 26 | ||
... | @@ -24,10 +30,10 @@ hil_cursor.execute(hil_sql) | ... | @@ -24,10 +30,10 @@ hil_cursor.execute(hil_sql) |
24 | hil_cursor.close() | 30 | hil_cursor.close() |
25 | hil_cnxn.close() | 31 | hil_cnxn.close() |
26 | 32 | ||
27 | # afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | 33 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) |
28 | # | 34 | |
29 | # afc_cursor = afc_cnxn.cursor() | 35 | afc_cursor = afc_cnxn.cursor() |
30 | # afc_cursor.execute(afc_sql) | 36 | afc_cursor.execute(afc_sql) |
31 | # | 37 | |
32 | # afc_cursor.close() | 38 | afc_cursor.close() |
33 | # afc_cnxn.close() | 39 | afc_cnxn.close() | ... | ... |
-
Please register or sign in to post a comment