add compare report se
Showing
2 changed files
with
92 additions
and
3 deletions
... | @@ -997,3 +997,41 @@ class InterfaceReport(models.Model): | ... | @@ -997,3 +997,41 @@ class InterfaceReport(models.Model): |
997 | class Meta: | 997 | class Meta: |
998 | managed = False | 998 | managed = False |
999 | db_table = 'interface_report' | 999 | db_table = 'interface_report' |
1000 | |||
1001 | |||
1002 | class HILCompareReportNew(models.Model): | ||
1003 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
1004 | application_id = models.CharField(max_length=64, verbose_name="申请id") | ||
1005 | |||
1006 | is_se = models.BooleanField(default=True, verbose_name="是否Settlement") | ||
1007 | is_auto = models.BooleanField(default=False, verbose_name="是否Settlement Auto") | ||
1008 | is_pass = models.BooleanField(default=False, verbose_name="是否全对") | ||
1009 | |||
1010 | full_result = models.TextField(null=True, verbose_name="完整比对结果") | ||
1011 | field_result = models.TextField(null=True, verbose_name="各证件字段统计") | ||
1012 | |||
1013 | start_time = models.DateTimeField(verbose_name='开始时间') # 索引 | ||
1014 | end_time = models.DateTimeField(verbose_name='结束时间') | ||
1015 | |||
1016 | class Meta: | ||
1017 | managed = False | ||
1018 | db_table = 'hil_compare_report_new' | ||
1019 | |||
1020 | |||
1021 | class AFCCompareReportNew(models.Model): | ||
1022 | id = models.AutoField(primary_key=True, verbose_name="id") # 主键 | ||
1023 | application_id = models.CharField(max_length=64, verbose_name="申请id") | ||
1024 | |||
1025 | is_se = models.BooleanField(default=True, verbose_name="是否Settlement") | ||
1026 | is_auto = models.BooleanField(default=False, verbose_name="是否Settlement Auto") | ||
1027 | is_pass = models.BooleanField(default=False, verbose_name="是否全对") | ||
1028 | |||
1029 | full_result = models.TextField(null=True, verbose_name="完整比对结果") | ||
1030 | field_result = models.TextField(null=True, verbose_name="各证件字段统计") | ||
1031 | |||
1032 | start_time = models.DateTimeField(verbose_name='开始时间') # 索引 | ||
1033 | end_time = models.DateTimeField(verbose_name='结束时间') | ||
1034 | |||
1035 | class Meta: | ||
1036 | managed = False | ||
1037 | db_table = 'afc_compare_report_new' | ... | ... |
... | @@ -32,6 +32,8 @@ from apps.doc.models import ( | ... | @@ -32,6 +32,8 @@ from apps.doc.models import ( |
32 | HILbankVerification, | 32 | HILbankVerification, |
33 | AFCbankVerification, | 33 | AFCbankVerification, |
34 | InterfaceReport, | 34 | InterfaceReport, |
35 | HILCompareReportNew, | ||
36 | AFCCompareReportNew, | ||
35 | ) | 37 | ) |
36 | from apps.doc import consts | 38 | from apps.doc import consts |
37 | from apps.doc.ocr.gcap import gcap | 39 | from apps.doc.ocr.gcap import gcap |
... | @@ -2843,6 +2845,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -2843,6 +2845,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
2843 | failure_reason = {} | 2845 | failure_reason = {} |
2844 | cn_reason_list = [] | 2846 | cn_reason_list = [] |
2845 | rpa_failure_reason = {} | 2847 | rpa_failure_reason = {} |
2848 | field_result_dict = {} | ||
2846 | 2849 | ||
2847 | for info_key, info_value in compare_info.items(): | 2850 | for info_key, info_value in compare_info.items(): |
2848 | if info_key in ['individualCusInfo', 'applicantInformation']: | 2851 | if info_key in ['individualCusInfo', 'applicantInformation']: |
... | @@ -2871,11 +2874,13 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -2871,11 +2874,13 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
2871 | else: | 2874 | else: |
2872 | result_field_list, no_ocr_result, field_img_path_dict = se_compare_license( | 2875 | result_field_list, no_ocr_result, field_img_path_dict = se_compare_license( |
2873 | license_en, ocr_res_dict, strip_list) | 2876 | license_en, ocr_res_dict, strip_list) |
2877 | each_license_failed_count = 0 | ||
2874 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | 2878 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: |
2875 | if license_en not in consts.SKIP_CARD or not no_ocr_result: | 2879 | if license_en not in consts.SKIP_CARD or not no_ocr_result: |
2876 | total_fields += 1 | 2880 | total_fields += 1 |
2877 | if result == consts.RESULT_N: | 2881 | if result == consts.RESULT_N: |
2878 | failed_count += 1 | 2882 | failed_count += 1 |
2883 | each_license_failed_count += 1 | ||
2879 | successful_at_this_level = False | 2884 | successful_at_this_level = False |
2880 | failure_field.append(name) | 2885 | failure_field.append(name) |
2881 | cn_reason_list.append(cn_reason) | 2886 | cn_reason_list.append(cn_reason) |
... | @@ -2896,6 +2901,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -2896,6 +2901,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
2896 | ) | 2901 | ) |
2897 | if len(failure_field) > 0: | 2902 | if len(failure_field) > 0: |
2898 | failure_reason.setdefault(info_key, []).append(';'.join(failure_field)) | 2903 | failure_reason.setdefault(info_key, []).append(';'.join(failure_field)) |
2904 | field_result_dict.setdefault(license_en, []).append('{0}/{1}'.format( | ||
2905 | each_license_failed_count, len(result_field_list))) | ||
2899 | else: | 2906 | else: |
2900 | for license_en, field_list in info_value.items(): | 2907 | for license_en, field_list in info_value.items(): |
2901 | strip_list = [] | 2908 | strip_list = [] |
... | @@ -2922,12 +2929,14 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -2922,12 +2929,14 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
2922 | else: | 2929 | else: |
2923 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) | 2930 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) |
2924 | 2931 | ||
2932 | each_license_failed_count = 0 | ||
2925 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | 2933 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: |
2926 | total_fields += 1 | 2934 | total_fields += 1 |
2927 | if result == consts.RESULT_N: | 2935 | if result == consts.RESULT_N: |
2928 | # if license_en != consts.MVI_EN or name != consts.SE_NEW_ADD_FIELD[9]: | 2936 | # if license_en != consts.MVI_EN or name != consts.SE_NEW_ADD_FIELD[9]: |
2929 | successful_at_this_level = False | 2937 | successful_at_this_level = False |
2930 | failed_count += 1 | 2938 | failed_count += 1 |
2939 | each_license_failed_count += 1 | ||
2931 | failure_field.append(name) | 2940 | failure_field.append(name) |
2932 | if isinstance(cn_reason, str): | 2941 | if isinstance(cn_reason, str): |
2933 | cn_reason_list.append(cn_reason) | 2942 | cn_reason_list.append(cn_reason) |
... | @@ -2951,6 +2960,9 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -2951,6 +2960,9 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
2951 | ) | 2960 | ) |
2952 | if len(failure_field) > 0: | 2961 | if len(failure_field) > 0: |
2953 | failure_reason.setdefault(info_key, []).append(';'.join(failure_field)) | 2962 | failure_reason.setdefault(info_key, []).append(';'.join(failure_field)) |
2963 | field_result_dict.setdefault(license_en, []).append('{0}/{1}'.format( | ||
2964 | each_license_failed_count, len(result_field_list))) | ||
2965 | |||
2954 | if failed_count == 0: | 2966 | if failed_count == 0: |
2955 | failure_reason_str = '' | 2967 | failure_reason_str = '' |
2956 | cn_failure_reason_str = '' | 2968 | cn_failure_reason_str = '' |
... | @@ -2977,7 +2989,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -2977,7 +2989,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
2977 | last_cn_reason_list.append(i) | 2989 | last_cn_reason_list.append(i) |
2978 | cn_failure_reason_str = '\n'.join(last_cn_reason_list) | 2990 | cn_failure_reason_str = '\n'.join(last_cn_reason_list) |
2979 | bs_failure_reason_str = '\n'.join(bs_cn_reason_list) | 2991 | bs_failure_reason_str = '\n'.join(bs_cn_reason_list) |
2980 | return compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason | 2992 | return compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ |
2993 | cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason, field_result_dict | ||
2981 | 2994 | ||
2982 | 2995 | ||
2983 | def se_result_detect(ocr_res_dict): | 2996 | def se_result_detect(ocr_res_dict): |
... | @@ -2990,13 +3003,14 @@ def se_result_detect(ocr_res_dict): | ... | @@ -2990,13 +3003,14 @@ def se_result_detect(ocr_res_dict): |
2990 | 3003 | ||
2991 | 3004 | ||
2992 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank, id_res_list): | 3005 | def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, auto_obj, ignore_bank, id_res_list): |
3006 | start_time = datetime.now() | ||
2993 | try: | 3007 | try: |
2994 | # 比对逻辑 | 3008 | # 比对逻辑 |
2995 | # detect_list = se_result_detect(ocr_res_dict) | 3009 | # detect_list = se_result_detect(ocr_res_dict) |
2996 | compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto( | 3010 | compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto( |
2997 | last_obj, application_entity, ignore_bank=ignore_bank) | 3011 | last_obj, application_entity, ignore_bank=ignore_bank) |
2998 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ | 3012 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ |
2999 | cn_failure_reason_str, bs_failure_reason_str, _ = se_compare_process( | 3013 | cn_failure_reason_str, bs_failure_reason_str, _, field_result_dict = se_compare_process( |
3000 | compare_info, ocr_res_dict, is_gsyh, True, id_res_list) | 3014 | compare_info, ocr_res_dict, is_gsyh, True, id_res_list) |
3001 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 3015 | compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
3002 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 3016 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
... | @@ -3032,6 +3046,25 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc | ... | @@ -3032,6 +3046,25 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc |
3032 | # '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | 3046 | # '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, |
3033 | # traceback.format_exc())) | 3047 | # traceback.format_exc())) |
3034 | 3048 | ||
3049 | # 新的Report表 | ||
3050 | try: | ||
3051 | end_time = datetime.now() | ||
3052 | new_report_tabel = HILCompareReportNew if application_entity == consts.HIL_PREFIX else AFCCompareReportNew | ||
3053 | new_report_tabel.objects.create( | ||
3054 | application_id=application_id, | ||
3055 | is_se=True, | ||
3056 | is_auto=True, | ||
3057 | is_pass=successful_at_this_level, | ||
3058 | full_result=json.dumps(compare_result), | ||
3059 | field_result=json.dumps(field_result_dict), | ||
3060 | start_time=start_time, | ||
3061 | end_time=end_time, | ||
3062 | ) | ||
3063 | except Exception as e: | ||
3064 | compare_log.error('{0} [Auto SE] [db save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
3065 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
3066 | traceback.format_exc())) | ||
3067 | |||
3035 | return successful_at_this_level | 3068 | return successful_at_this_level |
3036 | 3069 | ||
3037 | 3070 | ||
... | @@ -3044,7 +3077,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -3044,7 +3077,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
3044 | compare_info, application_version, is_gsyh = get_se_cms_compare_info( | 3077 | compare_info, application_version, is_gsyh = get_se_cms_compare_info( |
3045 | last_obj, application_entity, detect_list, ignore_bank=ignore_bank) | 3078 | last_obj, application_entity, detect_list, ignore_bank=ignore_bank) |
3046 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ | 3079 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \ |
3047 | cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason = se_compare_process( | 3080 | cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason, field_result_dict = se_compare_process( |
3048 | compare_info, ocr_res_dict, is_gsyh, False, id_res_list) | 3081 | compare_info, ocr_res_dict, is_gsyh, False, id_res_list) |
3049 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 3082 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
3050 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 3083 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
... | @@ -3102,6 +3135,24 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -3102,6 +3135,24 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
3102 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | 3135 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, |
3103 | traceback.format_exc())) | 3136 | traceback.format_exc())) |
3104 | 3137 | ||
3138 | # 新的Report表 | ||
3139 | try: | ||
3140 | new_report_tabel = HILCompareReportNew if application_entity == consts.HIL_PREFIX else AFCCompareReportNew | ||
3141 | new_report_tabel.objects.create( | ||
3142 | application_id=application_id, | ||
3143 | is_se=True, | ||
3144 | is_auto=False, | ||
3145 | is_pass=successful_at_this_level, | ||
3146 | full_result=json.dumps(compare_result), | ||
3147 | field_result=json.dumps(field_result_dict), | ||
3148 | start_time=start_time, | ||
3149 | end_time=end_time, | ||
3150 | ) | ||
3151 | except Exception as e: | ||
3152 | compare_log.error('{0} [SE] [db save error] [entity={1}] [id={2}] [ocr_res_id={3}] ' | ||
3153 | '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id, | ||
3154 | traceback.format_exc())) | ||
3155 | |||
3105 | # cms结果发送 | 3156 | # cms结果发送 |
3106 | is_cms_send = Configs.objects.filter(id=2).first() | 3157 | is_cms_send = Configs.objects.filter(id=2).first() |
3107 | if is_cms_send is not None and is_cms_send.value == 'N': | 3158 | if is_cms_send is not None and is_cms_send.value == 'N': | ... | ... |
-
Please register or sign in to post a comment