add diff value
Showing
2 changed files
with
31 additions
and
14 deletions
| ... | @@ -45,8 +45,8 @@ class GCAP: | ... | @@ -45,8 +45,8 @@ class GCAP: |
| 45 | 'customerType': 'TCDAS', | 45 | 'customerType': 'TCDAS', |
| 46 | 'customerChineseName': 'co-app-name', | 46 | 'customerChineseName': 'co-app-name', |
| 47 | 'idNum': 'idNum', | 47 | 'idNum': 'idNum', |
| 48 | 'idExpiryDate': '2020-02-02T15:52:18.1049637+08:00', | 48 | 'idExpiryDate': '2020-02-02', |
| 49 | 'dateOfBirth': '2020-02-02T15:52:18.1049637+08:00', | 49 | 'dateOfBirth': '2020-02-02', |
| 50 | 'customerChineseNameResult': 'Y', | 50 | 'customerChineseNameResult': 'Y', |
| 51 | 'idNumResult': 'Y', | 51 | 'idNumResult': 'Y', |
| 52 | 'secondIdNumResult': 'Y', | 52 | 'secondIdNumResult': 'Y', |
| ... | @@ -59,8 +59,8 @@ class GCAP: | ... | @@ -59,8 +59,8 @@ class GCAP: |
| 59 | 'customerType': 'TCDAS', | 59 | 'customerType': 'TCDAS', |
| 60 | 'customerChineseName': 'ga1-name', | 60 | 'customerChineseName': 'ga1-name', |
| 61 | 'idNum': 'id3', | 61 | 'idNum': 'id3', |
| 62 | 'idExpiryDate': '2020-03-03T15:52:18.1049637+08:00', | 62 | 'idExpiryDate': '2020-03-03', |
| 63 | 'dateOfBirth': '2020-03-03T15:52:18.1049637+08:00', | 63 | 'dateOfBirth': '2020-03-03', |
| 64 | 'customerChineseNameResult': 'Y', | 64 | 'customerChineseNameResult': 'Y', |
| 65 | 'idNumResult': 'Y', | 65 | 'idNumResult': 'Y', |
| 66 | 'secondIdNumResult': 'Y', | 66 | 'secondIdNumResult': 'Y', |
| ... | @@ -73,8 +73,8 @@ class GCAP: | ... | @@ -73,8 +73,8 @@ class GCAP: |
| 73 | 'customerType': 'TCDAS', | 73 | 'customerType': 'TCDAS', |
| 74 | 'customerChineseName': 'ga2-name', | 74 | 'customerChineseName': 'ga2-name', |
| 75 | 'idNum': 'id4', | 75 | 'idNum': 'id4', |
| 76 | 'idExpiryDate': '2020-04-04T15:52:18.1049637+08:00', | 76 | 'idExpiryDate': '2020-04-04', |
| 77 | 'dateOfBirth': '2020-04-04T15:52:18.1049637+08:00', | 77 | 'dateOfBirth': '2020-04-04', |
| 78 | 'customerChineseNameResult': 'Y', | 78 | 'customerChineseNameResult': 'Y', |
| 79 | 'idNumResult': 'Y', | 79 | 'idNumResult': 'Y', |
| 80 | 'secondIdNumResult': 'Y', | 80 | 'secondIdNumResult': 'Y', |
| ... | @@ -84,8 +84,8 @@ class GCAP: | ... | @@ -84,8 +84,8 @@ class GCAP: |
| 84 | ], | 84 | ], |
| 85 | 'usedCarInfo': { | 85 | 'usedCarInfo': { |
| 86 | 'vinNo': 'LBVSFJSDLFJLSDJF', | 86 | 'vinNo': 'LBVSFJSDLFJLSDJF', |
| 87 | 'manufactureDate': '2020-09-03T15:52:18.1049637+08:00', | 87 | 'manufactureDate': '2020-09-03', |
| 88 | 'firstRegistrationDate': '2020-09-03T15:52:18.1049637+08:00', | 88 | 'firstRegistrationDate': '2020-09-03', |
| 89 | 'vinNoResult': 'Y', | 89 | 'vinNoResult': 'Y', |
| 90 | 'manufactureDateResult': 'Y', | 90 | 'manufactureDateResult': 'Y', |
| 91 | 'firstRegistrationDateResult': 'Y', | 91 | 'firstRegistrationDateResult': 'Y', |
| ... | @@ -97,8 +97,8 @@ class GCAP: | ... | @@ -97,8 +97,8 @@ class GCAP: |
| 97 | 'customerType': 'TCCOR', | 97 | 'customerType': 'TCCOR', |
| 98 | 'businessLicenseNo': 'MA007438143XJ1P', | 98 | 'businessLicenseNo': 'MA007438143XJ1P', |
| 99 | 'taxRegistrationCode': 'MA007438143XJ1P', | 99 | 'taxRegistrationCode': 'MA007438143XJ1P', |
| 100 | 'incorporationDate': '2020-09-02T15:52:18.1049637+08:00', | 100 | 'incorporationDate': '2020-09-02', |
| 101 | 'businessLicenseDueDate': '2020-09-02T15:52:18.1049637+08:00', | 101 | 'businessLicenseDueDate': '2020-09-02', |
| 102 | 'capitalRegAmount': '60000000', | 102 | 'capitalRegAmount': '60000000', |
| 103 | 'customerChinessNameResult': 'Y', | 103 | 'customerChinessNameResult': 'Y', |
| 104 | 'legalRepNameResult': 'Y', | 104 | 'legalRepNameResult': 'Y', | ... | ... |
| ... | @@ -22,8 +22,9 @@ def get_order_dict(src_dict, order_tuple): | ... | @@ -22,8 +22,9 @@ def get_order_dict(src_dict, order_tuple): |
| 22 | return order_dict | 22 | return order_dict |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set): | 25 | def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, diff_idx=None): |
| 26 | is_find = False | 26 | is_find = False |
| 27 | find_dict = {} | ||
| 27 | ocr_res_str = ocr_res_dict.get(ocr_field) | 28 | ocr_res_str = ocr_res_dict.get(ocr_field) |
| 28 | if ocr_res_str is not None: | 29 | if ocr_res_str is not None: |
| 29 | ocr_res_list = json.loads(ocr_res_str) | 30 | ocr_res_list = json.loads(ocr_res_str) |
| ... | @@ -37,12 +38,28 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set): | ... | @@ -37,12 +38,28 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set): |
| 37 | if idx == 0 and compare_res == consts.RESULT_N and res_len != 1: | 38 | if idx == 0 and compare_res == consts.RESULT_N and res_len != 1: |
| 38 | break | 39 | break |
| 39 | is_find = True | 40 | is_find = True |
| 41 | find_dict = ocr_res | ||
| 40 | info_dict[compare_tuple[0] + 'Result'] = compare_res | 42 | info_dict[compare_tuple[0] + 'Result'] = compare_res |
| 41 | res_set.add(compare_res) | 43 | res_set.add(compare_res) |
| 42 | if not is_find: | 44 | if not is_find: |
| 43 | res_set.add(consts.RESULT_N) | 45 | res_set.add(consts.RESULT_N) |
| 44 | for compare_tuple in compare_list: | 46 | for compare_tuple in compare_list: |
| 45 | info_dict[compare_tuple[0] + 'Result'] = consts.RESULT_N | 47 | info_dict[compare_tuple[0] + 'Result'] = consts.RESULT_N |
| 48 | if diff_idx is not None: | ||
| 49 | diff_field = compare_list[diff_idx][0] + 'Result' | ||
| 50 | if info_dict.get(diff_field) == consts.RESULT_N: | ||
| 51 | if is_find: | ||
| 52 | diff_value = find_dict.get(compare_list[diff_idx][1], consts.RESULT_N) | ||
| 53 | elif ocr_res_str is not None: | ||
| 54 | for ocr_res in ocr_res_list: | ||
| 55 | if ocr_res.get(compare_list[diff_idx][1]): | ||
| 56 | diff_value = ocr_res.get(compare_list[diff_idx][1]) | ||
| 57 | break | ||
| 58 | else: | ||
| 59 | diff_value = consts.RESULT_N | ||
| 60 | else: | ||
| 61 | diff_value = consts.RESULT_N | ||
| 62 | info_dict[diff_field] = diff_value | ||
| 46 | 63 | ||
| 47 | 64 | ||
| 48 | @app.task | 65 | @app.task |
| ... | @@ -98,7 +115,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -98,7 +115,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
| 98 | order_individual_cus_info = get_order_dict(individual_cus_info, consts.IN_ORDER) | 115 | order_individual_cus_info = get_order_dict(individual_cus_info, consts.IN_ORDER) |
| 99 | # sep营业执照 | 116 | # sep营业执照 |
| 100 | if is_sep and order_individual_cus_info.get('companyName') is not None: | 117 | if is_sep and order_individual_cus_info.get('companyName') is not None: |
| 101 | field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set) | 118 | field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set, 2) |
| 102 | 119 | ||
| 103 | # 个人信息证件 | 120 | # 个人信息证件 |
| 104 | id_type = order_individual_cus_info.get('idType') | 121 | id_type = order_individual_cus_info.get('idType') |
| ... | @@ -115,10 +132,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -115,10 +132,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
| 115 | usedcar_info = json.loads(last_obj.usedcar_info) | 132 | usedcar_info = json.loads(last_obj.usedcar_info) |
| 116 | order_usedcar_info = get_order_dict(usedcar_info, consts.UC_ORDER) | 133 | order_usedcar_info = get_order_dict(usedcar_info, consts.UC_ORDER) |
| 117 | 134 | ||
| 118 | field_compare(order_usedcar_info, ocr_res_dict, consts.MVC_OCR_FIELD, consts.PCUSD_MVC, res_set) | 135 | field_compare(order_usedcar_info, ocr_res_dict, consts.MVC_OCR_FIELD, consts.PCUSD_MVC, res_set, 0) |
| 119 | 136 | ||
| 120 | if order_usedcar_info[consts.PCUSD_MVC[0][0] + 'Result'] == consts.RESULT_Y: | 137 | if order_usedcar_info[consts.PCUSD_MVC[0][0] + 'Result'] == consts.RESULT_Y: |
| 121 | field_compare(order_usedcar_info, ocr_res_dict, consts.DL_OCR_FIELD, consts.PCUSD_DL, res_set) | 138 | field_compare(order_usedcar_info, ocr_res_dict, consts.DL_OCR_FIELD, consts.PCUSD_DL, res_set, 0) |
| 122 | 139 | ||
| 123 | comparison_res['OCR_Input']['usedCarInfo'] = order_usedcar_info | 140 | comparison_res['OCR_Input']['usedCarInfo'] = order_usedcar_info |
| 124 | 141 | ... | ... |
-
Please register or sign in to post a comment