add bankcard
Showing
5 changed files
with
104 additions
and
35 deletions
... | @@ -882,3 +882,25 @@ class AFCAutoSettlement(models.Model): | ... | @@ -882,3 +882,25 @@ class AFCAutoSettlement(models.Model): |
882 | situ_db_label = 'afc' | 882 | situ_db_label = 'afc' |
883 | 883 | ||
884 | 884 | ||
885 | class HILbankVerification(models.Model): | ||
886 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
887 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
888 | on_off = models.BooleanField(default=True, verbose_name="是否有效") | ||
889 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
890 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
891 | |||
892 | class Meta: | ||
893 | managed = False | ||
894 | db_table = 'hil_bank_verification' | ||
895 | |||
896 | |||
897 | class AFCbankVerification(models.Model): | ||
898 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
899 | application_id = models.CharField(max_length=64, verbose_name="申请id") # 索引 | ||
900 | on_off = models.BooleanField(default=True, verbose_name="是否有效") | ||
901 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | ||
902 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ||
903 | |||
904 | class Meta: | ||
905 | managed = False | ||
906 | db_table = 'afc_bank_verification' | ... | ... |
... | @@ -495,7 +495,7 @@ class BSWorkbook(Workbook): | ... | @@ -495,7 +495,7 @@ class BSWorkbook(Workbook): |
495 | high_light_keyword = self.wechat_keyword | 495 | high_light_keyword = self.wechat_keyword |
496 | else: | 496 | else: |
497 | high_light_keyword = self.loan_keyword | 497 | high_light_keyword = self.loan_keyword |
498 | for month in sorted(month_mapping.keys()): | 498 | for month in sorted(month_mapping.keys(), reverse=True): |
499 | # 3.1.拷贝数据 | 499 | # 3.1.拷贝数据 |
500 | parts = month_mapping.get(month) | 500 | parts = month_mapping.get(month) |
501 | new_ws = self.create_sheet('{0}({1})'.format(month, card)) | 501 | new_ws = self.create_sheet('{0}({1})'.format(month, card)) | ... | ... |
... | @@ -42,6 +42,8 @@ from .models import ( | ... | @@ -42,6 +42,8 @@ from .models import ( |
42 | HILSECompareResultRecord, | 42 | HILSECompareResultRecord, |
43 | HILAutoSettlement, | 43 | HILAutoSettlement, |
44 | AFCAutoSettlement, | 44 | AFCAutoSettlement, |
45 | HILbankVerification, | ||
46 | AFCbankVerification, | ||
45 | ) | 47 | ) |
46 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult | 48 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult |
47 | from .mixins import DocHandler, MPOSHandler | 49 | from .mixins import DocHandler, MPOSHandler |
... | @@ -112,7 +114,7 @@ se_bank_args = { | ... | @@ -112,7 +114,7 @@ se_bank_args = { |
112 | 'applicantType': fields.Str(required=True, validate=validate.Length(max=16)), | 114 | 'applicantType': fields.Str(required=True, validate=validate.Length(max=16)), |
113 | 'accountHolderName': fields.Str(required=True, validate=validate.Length(max=256)), | 115 | 'accountHolderName': fields.Str(required=True, validate=validate.Length(max=256)), |
114 | 'accountNo': fields.Str(required=True, validate=validate.Length(max=256)), | 116 | 'accountNo': fields.Str(required=True, validate=validate.Length(max=256)), |
115 | 'bankVerificationStatus': fields.Str(required=False, validate=validate.Length(max=16)), | 117 | 'bankVerificationStatus': fields.Str(required=False, validate=validate.Length(max=128)), |
116 | 'isAllDocUploaded': fields.Boolean(required=False) | 118 | 'isAllDocUploaded': fields.Boolean(required=False) |
117 | } | 119 | } |
118 | 120 | ||
... | @@ -748,29 +750,25 @@ class SECompareView(GenericView): | ... | @@ -748,29 +750,25 @@ class SECompareView(GenericView): |
748 | @use_args(se_compare_args, location='data') | 750 | @use_args(se_compare_args, location='data') |
749 | def post(self, request, args): | 751 | def post(self, request, args): |
750 | # 存库 | 752 | # 存库 |
751 | # content = args.get('content', {}) | 753 | content = args.get('content', {}) |
752 | # business_type = content.get('applicationEntity') | 754 | business_type = content.get('applicationEntity') |
753 | # application_id = content.get('applicationId') | 755 | application_id = content.get('applicationId') |
754 | # is_auto = content.get('isAutoSettlement', False) | 756 | bank_verify = content.get('bankInfo', {}).get('bankVerificationStatus', '') |
755 | # | 757 | |
756 | # auto_class = HILAutoSettlement if business_type in consts.HIL_SET else AFCAutoSettlement | 758 | bank_class = HILbankVerification if business_type in consts.HIL_SET else AFCbankVerification |
757 | # auto_obj = auto_class.objects.filter(application_id=application_id).first() | 759 | bank_obj = bank_class.objects.filter(application_id=application_id).first() |
758 | # if is_auto: | 760 | |
759 | # # 加入优先级队列 | 761 | if bank_obj is None and bank_verify == 'PASS': |
760 | # PriorityApplication.objects.update_or_create( | 762 | bank_class.objects.create( |
761 | # application_id=application_id, defaults={'on_off': True}) | 763 | application_id=application_id, |
762 | # # 加入auto表 | 764 | ) |
763 | # if auto_obj is None: | 765 | elif bank_obj is not None and bank_verify == 'PASS' and bank_obj.on_off is False: |
764 | # auto_class.objects.create( | 766 | bank_obj.on_off = True |
765 | # application_id=application_id, | 767 | bank_obj.save() |
766 | # ) | 768 | elif bank_obj is not None and bank_verify != 'PASS' and bank_obj.on_off is True: |
767 | # elif auto_obj.on_off is False: | 769 | bank_obj.on_off = False |
768 | # auto_obj.on_off = True | 770 | bank_obj.save() |
769 | # auto_obj.save() | 771 | |
770 | # else: | ||
771 | # if auto_obj is not None and auto_obj.on_off is True: | ||
772 | # auto_obj.on_off = False | ||
773 | # auto_obj.save() | ||
774 | return response.ok() | 772 | return response.ok() |
775 | 773 | ||
776 | post.openapi_doc = ''' | 774 | post.openapi_doc = ''' | ... | ... |
... | @@ -29,6 +29,8 @@ from apps.doc.models import ( | ... | @@ -29,6 +29,8 @@ from apps.doc.models import ( |
29 | HILCACompareResult, | 29 | HILCACompareResult, |
30 | HILAutoSettlement, | 30 | HILAutoSettlement, |
31 | AFCAutoSettlement, | 31 | AFCAutoSettlement, |
32 | HILbankVerification, | ||
33 | AFCbankVerification, | ||
32 | ) | 34 | ) |
33 | from apps.doc import consts | 35 | from apps.doc import consts |
34 | from apps.doc.ocr.gcap import gcap | 36 | from apps.doc.ocr.gcap import gcap |
... | @@ -872,7 +874,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -872,7 +874,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
872 | traceback.format_exc())) | 874 | traceback.format_exc())) |
873 | 875 | ||
874 | 876 | ||
875 | def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | 877 | def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True, ignore_bank=False): |
876 | cms_info = json.loads(last_obj.content) | 878 | cms_info = json.loads(last_obj.content) |
877 | 879 | ||
878 | compare_info = {} | 880 | compare_info = {} |
... | @@ -1083,7 +1085,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1083,7 +1085,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1083 | 1085 | ||
1084 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: | 1086 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: |
1085 | pass | 1087 | pass |
1086 | else: | 1088 | elif not ignore_bank: |
1087 | bank_field_input = [ | 1089 | bank_field_input = [ |
1088 | ('accountNo', account_no), | 1090 | ('accountNo', account_no), |
1089 | ('bankName', bank_name), | 1091 | ('bankName', bank_name), |
... | @@ -1408,7 +1410,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): | ... | @@ -1408,7 +1410,7 @@ def get_se_cms_compare_info_auto(last_obj, application_entity, auto=True): |
1408 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh | 1410 | return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh |
1409 | 1411 | ||
1410 | 1412 | ||
1411 | def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=False): | 1413 | def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=False, ignore_bank=False): |
1412 | cms_info = json.loads(last_obj.content) | 1414 | cms_info = json.loads(last_obj.content) |
1413 | 1415 | ||
1414 | compare_info = {} | 1416 | compare_info = {} |
... | @@ -1618,7 +1620,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals | ... | @@ -1618,7 +1620,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list, auto=Fals |
1618 | 1620 | ||
1619 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: | 1621 | if isinstance(company_info, tuple) and company_info[0] == account_holder_name: |
1620 | pass | 1622 | pass |
1621 | else: | 1623 | elif not ignore_bank: |
1622 | bank_field_input = [ | 1624 | bank_field_input = [ |
1623 | ('accountNo', account_no), | 1625 | ('accountNo', account_no), |
1624 | ('bankName', bank_name), | 1626 | ('bankName', bank_name), |
... | @@ -2700,12 +2702,12 @@ def se_result_detect(ocr_res_dict): | ... | @@ -2700,12 +2702,12 @@ def se_result_detect(ocr_res_dict): |
2700 | return detect_list | 2702 | return detect_list |
2701 | 2703 | ||
2702 | 2704 | ||
2703 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj): | 2705 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank): |
2704 | try: | 2706 | try: |
2705 | # 比对逻辑 | 2707 | # 比对逻辑 |
2706 | # detect_list = se_result_detect(ocr_res_dict) | 2708 | # detect_list = se_result_detect(ocr_res_dict) |
2707 | compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto( | 2709 | compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto( |
2708 | last_obj, application_entity) | 2710 | last_obj, application_entity, ignore_bank=ignore_bank) |
2709 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str, _ = se_compare_process(compare_info, ocr_res_dict, is_gsyh, True) | 2711 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str, _ = se_compare_process(compare_info, ocr_res_dict, is_gsyh, True) |
2710 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 2712 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
2711 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 2713 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
... | @@ -2744,13 +2746,13 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc | ... | @@ -2744,13 +2746,13 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc |
2744 | return successful_at_this_level | 2746 | return successful_at_this_level |
2745 | 2747 | ||
2746 | 2748 | ||
2747 | def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result): | 2749 | def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result, ignore_bank): |
2748 | try: | 2750 | try: |
2749 | # 比对逻辑 | 2751 | # 比对逻辑 |
2750 | start_time = datetime.now() | 2752 | start_time = datetime.now() |
2751 | detect_list = se_result_detect(ocr_res_dict) | 2753 | detect_list = se_result_detect(ocr_res_dict) |
2752 | compare_info, application_version, is_gsyh = get_se_cms_compare_info( | 2754 | compare_info, application_version, is_gsyh = get_se_cms_compare_info( |
2753 | last_obj, application_entity, detect_list) | 2755 | last_obj, application_entity, detect_list, ignore_bank=ignore_bank) |
2754 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason = se_compare_process(compare_info, ocr_res_dict, is_gsyh, False) | 2756 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason = se_compare_process(compare_info, ocr_res_dict, is_gsyh, False) |
2755 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 2757 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
2756 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 2758 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
... | @@ -2903,12 +2905,14 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -2903,12 +2905,14 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
2903 | # auto settlement | 2905 | # auto settlement |
2904 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement | 2906 | auto_class = HILAutoSettlement if application_entity == consts.HIL_PREFIX else AFCAutoSettlement |
2905 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() | 2907 | auto_obj = auto_class.objects.filter(application_id=application_id, on_off=True).first() |
2908 | bank_class = HILbankVerification if application_entity == consts.HIL_PREFIX else AFCbankVerification | ||
2909 | ignore_bank = bank_class.objects.filter(application_id=application_id, on_off=True).exists() | ||
2906 | if auto_obj is not None: | 2910 | if auto_obj is not None: |
2907 | auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj) | 2911 | auto_result = se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank) |
2908 | else: | 2912 | else: |
2909 | auto_result = None | 2913 | auto_result = None |
2910 | 2914 | ||
2911 | full_result = se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result) | 2915 | full_result = se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms, auto_result, ignore_bank) |
2912 | 2916 | ||
2913 | if auto_obj is not None: | 2917 | if auto_obj is not None: |
2914 | try: | 2918 | try: | ... | ... |
src/common/tools/mssql_script18.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | create table hil_bank_verification | ||
5 | ( | ||
6 | id bigint identity primary key, | ||
7 | application_id nvarchar(64) not null, | ||
8 | on_off bit default 1 not null, | ||
9 | update_time datetime not null, | ||
10 | create_time datetime not null | ||
11 | ); | ||
12 | |||
13 | create index hil_bank_verification_application_id_index | ||
14 | on hil_bank_verification (application_id); | ||
15 | """ | ||
16 | |||
17 | afc_sql = """ | ||
18 | create table afc_bank_verification | ||
19 | ( | ||
20 | id bigint identity primary key, | ||
21 | application_id nvarchar(64) not null, | ||
22 | on_off bit default 1 not null, | ||
23 | update_time datetime not null, | ||
24 | create_time datetime not null | ||
25 | ); | ||
26 | |||
27 | create index afc_bank_verification_application_id_index | ||
28 | on afc_bank_verification (application_id); | ||
29 | """ | ||
30 | |||
31 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
32 | |||
33 | hil_cursor = hil_cnxn.cursor() | ||
34 | hil_cursor.execute(hil_sql) | ||
35 | |||
36 | hil_cursor.close() | ||
37 | hil_cnxn.close() | ||
38 | |||
39 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
40 | |||
41 | afc_cursor = afc_cnxn.cursor() | ||
42 | afc_cursor.execute(afc_sql) | ||
43 | |||
44 | afc_cursor.close() | ||
45 | afc_cnxn.close() |
-
Please register or sign in to post a comment