fix bug
Showing
3 changed files
with
33 additions
and
18 deletions
... | @@ -1083,23 +1083,26 @@ ID_TYPE_COMPARE = { | ... | @@ -1083,23 +1083,26 @@ ID_TYPE_COMPARE = { |
1083 | 'ITRES': [RP_OCR_FIELD, ITRES], | 1083 | 'ITRES': [RP_OCR_FIELD, ITRES], |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | ID_RES = 'idNumResult' | ||
1087 | SECOND_ID_RES = 'secondIdNumResult' | ||
1088 | |||
1086 | SECOND_ITPRC = [ | 1089 | SECOND_ITPRC = [ |
1087 | ('secondIdNum', '公民身份号码', 'common_compare', {}, 'secondIdNumResult'), | 1090 | ('secondIdNum', '公民身份号码', 'common_compare', {}, SECOND_ID_RES), |
1088 | ] | 1091 | ] |
1089 | 1092 | ||
1090 | # 护照 | 1093 | # 护照 |
1091 | SECOND_ITPSP = [ | 1094 | SECOND_ITPSP = [ |
1092 | ('secondIdNum', '护照号码', 'common_compare', {}, 'secondIdNumResult'), | 1095 | ('secondIdNum', '护照号码', 'common_compare', {}, SECOND_ID_RES), |
1093 | ] | 1096 | ] |
1094 | 1097 | ||
1095 | # 港澳台通行证 | 1098 | # 港澳台通行证 |
1096 | SECOND_ITHKM_ITTID = [ | 1099 | SECOND_ITHKM_ITTID = [ |
1097 | ('secondIdNum', '证件号码', 'common_compare', {}, 'secondIdNumResult'), | 1100 | ('secondIdNum', '证件号码', 'common_compare', {}, SECOND_ID_RES), |
1098 | ] | 1101 | ] |
1099 | 1102 | ||
1100 | # 居住证 | 1103 | # 居住证 |
1101 | SECOND_ITRES = [ | 1104 | SECOND_ITRES = [ |
1102 | ('secondIdNum', '公民身份号码', 'common_compare', {}, 'secondIdNumResult'), | 1105 | ('secondIdNum', '公民身份号码', 'common_compare', {}, SECOND_ID_RES), |
1103 | ] | 1106 | ] |
1104 | 1107 | ||
1105 | SECOND_ID_TYPE_COMPARE = { | 1108 | SECOND_ID_TYPE_COMPARE = { |
... | @@ -1128,7 +1131,7 @@ PCUSD_DL = [ | ... | @@ -1128,7 +1131,7 @@ PCUSD_DL = [ |
1128 | 1131 | ||
1129 | # 营业执照 | 1132 | # 营业执照 |
1130 | TCCOR = [ | 1133 | TCCOR = [ |
1131 | ('customerChineseName', '企业名称', 'common_compare', {}, 'customerChinessNameResult'), | 1134 | ('customerChineseName', '企业名称', 'company_compare', {}, 'customerChinessNameResult'), |
1132 | ('legalRepName', '经营者姓名', 'name_compare', {}, 'legalRepNameResult'), | 1135 | ('legalRepName', '经营者姓名', 'name_compare', {}, 'legalRepNameResult'), |
1133 | ('idNum', '注册号', 'common_compare', {}, 'idNumResult'), | 1136 | ('idNum', '注册号', 'common_compare', {}, 'idNumResult'), |
1134 | ('businessLicenseNo', '注册号', 'common_compare', {}, 'businessLicenseNoResult'), | 1137 | ('businessLicenseNo', '注册号', 'common_compare', {}, 'businessLicenseNoResult'), |
... | @@ -1140,7 +1143,7 @@ TCCOR = [ | ... | @@ -1140,7 +1143,7 @@ TCCOR = [ |
1140 | ] | 1143 | ] |
1141 | 1144 | ||
1142 | TCSEP = [ | 1145 | TCSEP = [ |
1143 | ('companyName', '企业名称', 'common_compare', {}, 'companyNameResult'), | 1146 | ('companyName', '企业名称', 'company_compare', {}, 'companyNameResult'), |
1144 | ('registeredCapital', '注册资本', 'rmb_compare', {}, 'registeredCapitalResult'), # 壹拾万元整 将OCR识别结果(人民币大写)转化为数字 | 1147 | ('registeredCapital', '注册资本', 'rmb_compare', {}, 'registeredCapitalResult'), # 壹拾万元整 将OCR识别结果(人民币大写)转化为数字 |
1145 | ('selfEmployedSubType', '企业类型', 'type_compare', {}, 'selfEmployedSubTypeResult') # 有限责任公司 | 1148 | ('selfEmployedSubType', '企业类型', 'type_compare', {}, 'selfEmployedSubTypeResult') # 有限责任公司 |
1146 | ] | 1149 | ] | ... | ... |
... | @@ -150,16 +150,22 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -150,16 +150,22 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
150 | # 个人信息证件 | 150 | # 个人信息证件 |
151 | id_type = order_individual_cus_info.get('idType') | 151 | id_type = order_individual_cus_info.get('idType') |
152 | compare_info_list = consts.ID_TYPE_COMPARE.get(id_type) | 152 | compare_info_list = consts.ID_TYPE_COMPARE.get(id_type) |
153 | if compare_info_list is None: | 153 | if compare_info_list is not None: |
154 | continue | ||
155 | field_compare(order_individual_cus_info, ocr_res_dict, compare_info_list[0], compare_info_list[1], res_set) | 154 | field_compare(order_individual_cus_info, ocr_res_dict, compare_info_list[0], compare_info_list[1], res_set) |
156 | 155 | ||
157 | # 第二证件 | 156 | # 第二证件 |
158 | second_id_type = order_individual_cus_info.get('secondIdType') | 157 | second_id_type = order_individual_cus_info.get('secondIdType') |
159 | second_compare_info_list = consts.SECOND_ID_TYPE_COMPARE.get(second_id_type) | 158 | second_compare_info_list = consts.SECOND_ID_TYPE_COMPARE.get(second_id_type) |
160 | if second_compare_info_list is None: | 159 | if second_compare_info_list is not None: |
161 | continue | ||
162 | field_compare(order_individual_cus_info, ocr_res_dict, second_compare_info_list[0], second_compare_info_list[1], res_set) | 160 | field_compare(order_individual_cus_info, ocr_res_dict, second_compare_info_list[0], second_compare_info_list[1], res_set) |
161 | # 重新排列 | ||
162 | new_dict = OrderedDict({}) | ||
163 | second_id_res = order_individual_cus_info.pop(consts.SECOND_ID_RES, consts.RESULT_NA) | ||
164 | for key, value in order_individual_cus_info.items(): | ||
165 | new_dict[key] = value | ||
166 | if key == consts.ID_RES: | ||
167 | new_dict[consts.SECOND_ID_RES] = second_id_res | ||
168 | order_individual_cus_info = new_dict | ||
163 | 169 | ||
164 | # sep营业执照 | 170 | # sep营业执照 |
165 | if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]: | 171 | if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]: | ... | ... |
... | @@ -27,6 +27,7 @@ class Comparison: | ... | @@ -27,6 +27,7 @@ class Comparison: |
27 | '·': '', | 27 | '·': '', |
28 | } | 28 | } |
29 | self.TRANS = str.maketrans(self.TRANS_MAP) | 29 | self.TRANS = str.maketrans(self.TRANS_MAP) |
30 | self.re_obj = r'[(\(].*?[\))]' | ||
30 | 31 | ||
31 | def build_res(self, result): | 32 | def build_res(self, result): |
32 | if result: | 33 | if result: |
... | @@ -41,22 +42,27 @@ class Comparison: | ... | @@ -41,22 +42,27 @@ class Comparison: |
41 | return self.RESULT_NA, ocr_str | 42 | return self.RESULT_NA, ocr_str |
42 | return self.build_res(input_str == ocr_str), ocr_str | 43 | return self.build_res(input_str == ocr_str), ocr_str |
43 | 44 | ||
45 | def company_compare(self, input_str, ocr_str, idx, **kwargs): | ||
46 | if ocr_str == '': | ||
47 | return self.RESULT_NA, None | ||
48 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): | ||
49 | return self.RESULT_NA, ocr_str | ||
50 | input_tmp = re.sub(self.re_obj, '', input_str).strip() | ||
51 | ocr_tmp = re.sub(self.re_obj, '', ocr_str).strip() | ||
52 | return self.build_res(input_tmp == ocr_tmp), ocr_str | ||
53 | |||
44 | def name_compare(self, input_str, ocr_str, idx, **kwargs): | 54 | def name_compare(self, input_str, ocr_str, idx, **kwargs): |
45 | if ocr_str == '': | 55 | if ocr_str == '': |
46 | return self.RESULT_NA, None | 56 | return self.RESULT_NA, None |
47 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): | 57 | if not isinstance(input_str, str) or not isinstance(ocr_str, str): |
48 | return self.RESULT_NA, ocr_str | 58 | return self.RESULT_NA, ocr_str |
49 | if kwargs.get('is_passport'): | 59 | if kwargs.get('is_passport'): |
50 | input_obj = re.search(r'[a-zA-Z]]!', input_str) | 60 | input_tmp = input_str.upper().replace(' ', '') |
51 | if input_obj: | 61 | ocr_tmp = ocr_str.upper().replace(' ', '') |
52 | input_s = input_obj.group() | 62 | if input_tmp.find(ocr_tmp) == -1: |
53 | ocr_obj = re.search(r'[a-zA-Z]]!', ocr_str) | ||
54 | if ocr_obj: | ||
55 | ocr_s = ocr_obj.group() | ||
56 | return self.build_res(input_s == ocr_s), ocr_str | ||
57 | return self.RESULT_N, ocr_str | 63 | return self.RESULT_N, ocr_str |
58 | else: | 64 | else: |
59 | return self.build_res((input_str == ocr_str)), ocr_str | 65 | return self.RESULT_Y, ocr_str |
60 | else: | 66 | else: |
61 | if re.search(r'[a-zA-Z]]', input_str): | 67 | if re.search(r'[a-zA-Z]]', input_str): |
62 | return self.RESULT_NA, ocr_str | 68 | return self.RESULT_NA, ocr_str | ... | ... |
-
Please register or sign in to post a comment