add result errorType
Showing
1 changed file
with
27 additions
and
24 deletions
... | @@ -23,11 +23,12 @@ from apps.doc.models import ( | ... | @@ -23,11 +23,12 @@ from apps.doc.models import ( |
23 | from apps.doc import consts | 23 | from apps.doc import consts |
24 | from apps.doc.ocr.gcap import gcap | 24 | from apps.doc.ocr.gcap import gcap |
25 | from apps.doc.exceptions import GCAPException | 25 | from apps.doc.exceptions import GCAPException |
26 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName | 26 | from apps.doc.named_enum import RequestTeam, RequestTrigger, ProcessName, ErrorType |
27 | from common.tools.comparison import cp | 27 | from common.tools.comparison import cp |
28 | 28 | ||
29 | compare_log = logging.getLogger('compare') | 29 | compare_log = logging.getLogger('compare') |
30 | log_base = '[Compare]' | 30 | log_base = '[Compare]' |
31 | empty_str = '' | ||
31 | 32 | ||
32 | 33 | ||
33 | def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_num, name): | 34 | def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_num, name): |
... | @@ -209,7 +210,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -209,7 +210,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
209 | 'applicationVersion': last_obj.application_version, | 210 | 'applicationVersion': last_obj.application_version, |
210 | 'vehicleStatus': last_obj.vehicle_status, | 211 | 'vehicleStatus': last_obj.vehicle_status, |
211 | 'wholeResult': 'N', | 212 | 'wholeResult': 'N', |
212 | 'wholeResultMessage': '', | 213 | 'wholeResultMessage': empty_str, |
213 | 'applicationLink': r'//china.bmw.corp/WINFS/SF-CN-data/SF3-CN-S/SF3-CN-S-1-New Business/CA/OCR II test', | 214 | 'applicationLink': r'//china.bmw.corp/WINFS/SF-CN-data/SF3-CN-S/SF3-CN-S-1-New Business/CA/OCR II test', |
214 | } | 215 | } |
215 | }) | 216 | }) |
... | @@ -230,7 +231,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -230,7 +231,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
230 | sep_name = order_individual_cus_info.get('customerChineseName') | 231 | sep_name = order_individual_cus_info.get('customerChineseName') |
231 | if isinstance(sep_name, str): | 232 | if isinstance(sep_name, str): |
232 | sep_name = sep_name.strip() | 233 | sep_name = sep_name.strip() |
233 | if sep_name == '': | 234 | if sep_name == empty_str: |
234 | sep_name = None | 235 | sep_name = None |
235 | else: | 236 | else: |
236 | sep_name = None | 237 | sep_name = None |
... | @@ -296,12 +297,12 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -296,12 +297,12 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
296 | consts.PCUSD_DL, res_set) | 297 | consts.PCUSD_DL, res_set) |
297 | 298 | ||
298 | if mvc_find is True and dl_find is False: | 299 | if mvc_find is True and dl_find is False: |
299 | vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' | 300 | vino = dl_vinos[-1] if len(dl_vinos) > 0 else empty_str |
300 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}-{1} {2} {3}-{4}'.format( | 301 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}-{1} {2} {3}-{4}'.format( |
301 | consts.PREFIX_MVC, consts.RESULT_Y, consts.SPLIT, consts.PREFIX_DL, vino) | 302 | consts.PREFIX_MVC, consts.RESULT_Y, consts.SPLIT, consts.PREFIX_DL, vino) |
302 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | 303 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N |
303 | elif mvc_find is False and dl_find is True: | 304 | elif mvc_find is False and dl_find is True: |
304 | vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' | 305 | vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else empty_str |
305 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}-{1} {2} {3}-{4}'.format( | 306 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}-{1} {2} {3}-{4}'.format( |
306 | consts.PREFIX_MVC, vino, consts.SPLIT, consts.PREFIX_DL, consts.RESULT_Y) | 307 | consts.PREFIX_MVC, vino, consts.SPLIT, consts.PREFIX_DL, consts.RESULT_Y) |
307 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | 308 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N |
... | @@ -310,8 +311,8 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -310,8 +311,8 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
310 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = None | 311 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = None |
311 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_NA | 312 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_NA |
312 | else: | 313 | else: |
313 | mvc_vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' | 314 | mvc_vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else empty_str |
314 | dl_vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' | 315 | dl_vino = dl_vinos[-1] if len(dl_vinos) > 0 else empty_str |
315 | vino = '{0}-{1} {2} {3}-{4}'.format( | 316 | vino = '{0}-{1} {2} {3}-{4}'.format( |
316 | consts.PREFIX_MVC, mvc_vino, consts.SPLIT, consts.PREFIX_DL, dl_vino) | 317 | consts.PREFIX_MVC, mvc_vino, consts.SPLIT, consts.PREFIX_DL, dl_vino) |
317 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino | 318 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino |
... | @@ -452,7 +453,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -452,7 +453,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
452 | failure_reason = '、'.join(reason_list) | 453 | failure_reason = '、'.join(reason_list) |
453 | 454 | ||
454 | else: | 455 | else: |
455 | failure_reason = '' | 456 | failure_reason = empty_str |
456 | 457 | ||
457 | request_trigger = RequestTrigger.SUBMITING.value if ocr_res_id is None else RequestTrigger.UPLOADING.value | 458 | request_trigger = RequestTrigger.SUBMITING.value if ocr_res_id is None else RequestTrigger.UPLOADING.value |
458 | report_class = HILCompareReport if application_entity == consts.HIL_PREFIX else AFCCompareReport | 459 | report_class = HILCompareReport if application_entity == consts.HIL_PREFIX else AFCCompareReport |
... | @@ -652,7 +653,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -652,7 +653,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
652 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | 653 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) |
653 | if not isinstance(ocr_str, str): | 654 | if not isinstance(ocr_str, str): |
654 | result = consts.RESULT_N | 655 | result = consts.RESULT_N |
655 | ocr_str = '' | 656 | ocr_str = empty_str |
656 | else: | 657 | else: |
657 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 658 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
658 | 659 | ||
... | @@ -670,11 +671,12 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -670,11 +671,12 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
670 | result = expiry_date_res | 671 | result = expiry_date_res |
671 | break | 672 | break |
672 | 673 | ||
673 | result_field_list.append((name, value, result, ocr_str)) | 674 | error_type = empty_str if result == consts.RESULT_Y else ErrorType.OCR.value |
675 | result_field_list.append((name, value, result, ocr_str, error_type)) | ||
674 | 676 | ||
675 | if not is_find: | 677 | if not is_find: |
676 | for name, value in field_list: | 678 | for name, value in field_list: |
677 | result_field_list.append((name, value, consts.RESULT_N, '')) | 679 | result_field_list.append((name, value, consts.RESULT_N, empty_str, ErrorType.NF.value)) |
678 | 680 | ||
679 | return result_field_list | 681 | return result_field_list |
680 | 682 | ||
... | @@ -698,11 +700,11 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -698,11 +700,11 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
698 | try: | 700 | try: |
699 | transfer_name = ocr_res_list[res_idx].get(consts.TRANSFER_NAME, [])[idx] | 701 | transfer_name = ocr_res_list[res_idx].get(consts.TRANSFER_NAME, [])[idx] |
700 | except Exception as e: | 702 | except Exception as e: |
701 | transfer_name = '' | 703 | transfer_name = empty_str |
702 | try: | 704 | try: |
703 | transfer_num = ocr_res_list[res_idx].get(consts.TRANSFER_NUM, [])[idx] | 705 | transfer_num = ocr_res_list[res_idx].get(consts.TRANSFER_NUM, [])[idx] |
704 | except Exception as e: | 706 | except Exception as e: |
705 | transfer_num = '' | 707 | transfer_num = empty_str |
706 | core_info = { | 708 | core_info = { |
707 | consts.TRANSFER_NAME: transfer_name, | 709 | consts.TRANSFER_NAME: transfer_name, |
708 | consts.TRANSFER_NUM: transfer_num, | 710 | consts.TRANSFER_NUM: transfer_num, |
... | @@ -729,14 +731,15 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -729,14 +731,15 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
729 | ocr_str = ocr_res.get(compare_logic[name][0]) | 731 | ocr_str = ocr_res.get(compare_logic[name][0]) |
730 | if not isinstance(ocr_str, str): | 732 | if not isinstance(ocr_str, str): |
731 | result = consts.RESULT_N | 733 | result = consts.RESULT_N |
732 | ocr_str = '' | 734 | ocr_str = empty_str |
733 | else: | 735 | else: |
734 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 736 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
735 | result_field_list.append((name, value, result, ocr_str)) | 737 | error_type = empty_str if result == consts.RESULT_Y else ErrorType.OCR.value |
738 | result_field_list.append((name, value, result, ocr_str, error_type)) | ||
736 | 739 | ||
737 | if not is_find: | 740 | if not is_find: |
738 | for name, value in field_list: | 741 | for name, value in field_list: |
739 | result_field_list.append((name, value, consts.RESULT_N, '')) | 742 | result_field_list.append((name, value, consts.RESULT_N, empty_str, ErrorType.NF.value)) |
740 | 743 | ||
741 | return result_field_list | 744 | return result_field_list |
742 | 745 | ||
... | @@ -759,7 +762,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -759,7 +762,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
759 | for license_en, field_list in license_dict.items(): | 762 | for license_en, field_list in license_dict.items(): |
760 | failure_field = [] | 763 | failure_field = [] |
761 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) | 764 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) |
762 | for name, value, result, ocr_str in result_field_list: | 765 | for name, value, result, ocr_str, error_type in result_field_list: |
763 | total_fields += 1 | 766 | total_fields += 1 |
764 | if result == consts.RESULT_N: | 767 | if result == consts.RESULT_N: |
765 | failed_count += 1 | 768 | failed_count += 1 |
... | @@ -774,9 +777,9 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -774,9 +777,9 @@ def se_compare_process(compare_info, ocr_res_dict): |
774 | 'Input': value, | 777 | 'Input': value, |
775 | 'OCR': ocr_str, | 778 | 'OCR': ocr_str, |
776 | 'Result': result, | 779 | 'Result': result, |
777 | 'Position': '', | 780 | 'Position': empty_str, |
778 | 'Image': '', | 781 | 'Image': empty_str, |
779 | 'errorType': '', | 782 | 'errorType': error_type, |
780 | } | 783 | } |
781 | ) | 784 | ) |
782 | failure_reason.setdefault(license_en, []).append('/'.join(failure_field)) | 785 | failure_reason.setdefault(license_en, []).append('/'.join(failure_field)) |
... | @@ -787,7 +790,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -787,7 +790,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
787 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list) | 790 | result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list) |
788 | else: | 791 | else: |
789 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) | 792 | result_field_list = se_compare_license(license_en, ocr_res_dict, field_list) |
790 | for name, value, result, ocr_str in result_field_list: | 793 | for name, value, result, ocr_str, error_type in result_field_list: |
791 | total_fields += 1 | 794 | total_fields += 1 |
792 | if result == consts.RESULT_N: | 795 | if result == consts.RESULT_N: |
793 | failed_count += 1 | 796 | failed_count += 1 |
... | @@ -802,9 +805,9 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -802,9 +805,9 @@ def se_compare_process(compare_info, ocr_res_dict): |
802 | 'Input': value, | 805 | 'Input': value, |
803 | 'OCR': ocr_str, | 806 | 'OCR': ocr_str, |
804 | 'Result': result, | 807 | 'Result': result, |
805 | 'Position': '', | 808 | 'Position': empty_str, |
806 | 'Image': '', | 809 | 'Image': empty_str, |
807 | 'errorType': '', | 810 | 'errorType': error_type, |
808 | } | 811 | } |
809 | ) | 812 | ) |
810 | failure_reason.setdefault(license_en, []).append('/'.join(failure_field)) | 813 | failure_reason.setdefault(license_en, []).append('/'.join(failure_field)) | ... | ... |
-
Please register or sign in to post a comment