Merge branch 'feature/ca_compare' into feature/0611
Showing
3 changed files
with
34 additions
and
18 deletions
... | @@ -1057,6 +1057,7 @@ IC_RES_MAPPING = { | ... | @@ -1057,6 +1057,7 @@ IC_RES_MAPPING = { |
1057 | # ----------------- compare --------------------- | 1057 | # ----------------- compare --------------------- |
1058 | ENTITY = ['HIL', 'AFC'] | 1058 | ENTITY = ['HIL', 'AFC'] |
1059 | CUSTOMER_TYPE = ['TCCOR', 'TCDAS', 'TCFRE', 'TCIAS', 'TCIND', 'TCSEP', 'TCURE'] | 1059 | CUSTOMER_TYPE = ['TCCOR', 'TCDAS', 'TCFRE', 'TCIAS', 'TCIND', 'TCSEP', 'TCURE'] |
1060 | NO_COMPARE_CUSTOMER_TYPE = ['TCFRE', 'TCIND'] | ||
1060 | VEHICLE_STATUS = ['PCUSD', 'PCNEW'] | 1061 | VEHICLE_STATUS = ['PCUSD', 'PCNEW'] |
1061 | 1062 | ||
1062 | APPLICANT_TYPE = ['COAPP', 'CUSTR', 'GAUTR1', 'GAUTR2'] | 1063 | APPLICANT_TYPE = ['COAPP', 'CUSTR', 'GAUTR1', 'GAUTR2'] | ... | ... |
... | @@ -17,10 +17,10 @@ log_base = '[CA Compare]' | ... | @@ -17,10 +17,10 @@ log_base = '[CA Compare]' |
17 | 17 | ||
18 | 18 | ||
19 | def get_order_dict(src_dict, order_tuple): | 19 | def get_order_dict(src_dict, order_tuple): |
20 | if consts.SECOND_ID_TYPE_FIELD in src_dict: | 20 | # if consts.SECOND_ID_TYPE_FIELD in src_dict: |
21 | if src_dict.get(consts.SECOND_ID_TYPE_FIELD) not in consts.SECOND_ID_TYPE_COMPARE: | 21 | # if src_dict.get(consts.SECOND_ID_TYPE_FIELD) not in consts.SECOND_ID_TYPE_COMPARE: |
22 | src_dict.pop(consts.SECOND_ID_TYPE_FIELD, None) | 22 | # src_dict.pop(consts.SECOND_ID_TYPE_FIELD, None) |
23 | src_dict.pop(consts.SECOND_ID_FIELD, None) | 23 | # src_dict.pop(consts.SECOND_ID_FIELD, None) |
24 | 24 | ||
25 | order_dict = OrderedDict({}) | 25 | order_dict = OrderedDict({}) |
26 | for field in order_tuple: | 26 | for field in order_tuple: |
... | @@ -29,7 +29,15 @@ def get_order_dict(src_dict, order_tuple): | ... | @@ -29,7 +29,15 @@ def get_order_dict(src_dict, order_tuple): |
29 | return order_dict | 29 | return order_dict |
30 | 30 | ||
31 | 31 | ||
32 | def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has_expiry_date=False, sep_name=None): | 32 | def do_not_compare(info_dict, compare_list): |
33 | for compare_tuple in compare_list: | ||
34 | info_dict[compare_tuple[4]] = consts.RESULT_NA | ||
35 | if compare_tuple[0] in info_dict: | ||
36 | del info_dict[compare_tuple[0]] | ||
37 | |||
38 | |||
39 | def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, | ||
40 | has_expiry_date=False, sep_name=None, capital_ignore=False): | ||
33 | is_find = False | 41 | is_find = False |
34 | ocr_res_str = ocr_res_dict.get(ocr_field) | 42 | ocr_res_str = ocr_res_dict.get(ocr_field) |
35 | if ocr_res_str is not None: | 43 | if ocr_res_str is not None: |
... | @@ -91,7 +99,8 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has | ... | @@ -91,7 +99,8 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has |
91 | del info_dict[compare_tuple[0]] | 99 | del info_dict[compare_tuple[0]] |
92 | else: | 100 | else: |
93 | info_dict[compare_tuple[0]] = ocr_output | 101 | info_dict[compare_tuple[0]] = ocr_output |
94 | res_set.add(compare_res) | 102 | if not capital_ignore or idx != 1: |
103 | res_set.add(compare_res) | ||
95 | if not is_find: | 104 | if not is_find: |
96 | res_set.add(consts.RESULT_N) | 105 | res_set.add(consts.RESULT_N) |
97 | for compare_tuple in compare_list: | 106 | for compare_tuple in compare_list: |
... | @@ -208,8 +217,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -208,8 +217,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
208 | for individual_cus_info in individual_cus_info_list: | 217 | for individual_cus_info in individual_cus_info_list: |
209 | order_individual_cus_info = get_order_dict(individual_cus_info, consts.IN_ORDER) | 218 | order_individual_cus_info = get_order_dict(individual_cus_info, consts.IN_ORDER) |
210 | 219 | ||
220 | cus_type = order_individual_cus_info.get('customerType') | ||
221 | |||
211 | # 获取sep下营业执照法人代表 | 222 | # 获取sep下营业执照法人代表 |
212 | if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]: | 223 | if cus_type == consts.CUSTOMER_TYPE[5]: |
213 | sep_name = order_individual_cus_info.get('customerChineseName') | 224 | sep_name = order_individual_cus_info.get('customerChineseName') |
214 | if isinstance(sep_name, str): | 225 | if isinstance(sep_name, str): |
215 | sep_name = sep_name.strip() | 226 | sep_name = sep_name.strip() |
... | @@ -220,17 +231,22 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -220,17 +231,22 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
220 | 231 | ||
221 | # 个人信息证件 | 232 | # 个人信息证件 |
222 | id_type = order_individual_cus_info.get('idType') | 233 | id_type = order_individual_cus_info.get('idType') |
223 | if id_type not in consts.ID_TYPE_COMPARE: | 234 | if cus_type in consts.NO_COMPARE_CUSTOMER_TYPE or id_type not in consts.ID_TYPE_COMPARE: |
224 | continue | 235 | do_not_compare(order_individual_cus_info, consts.ITPRC) |
225 | ocr_field, compare_list, has_expiry_date = consts.ID_TYPE_COMPARE.get(id_type) | 236 | else: |
226 | field_compare(order_individual_cus_info, ocr_res_dict, ocr_field, compare_list, res_set, | 237 | ocr_field, compare_list, has_expiry_date = consts.ID_TYPE_COMPARE.get(id_type) |
227 | has_expiry_date=has_expiry_date) | 238 | field_compare(order_individual_cus_info, ocr_res_dict, ocr_field, compare_list, res_set, |
239 | has_expiry_date=has_expiry_date) | ||
228 | 240 | ||
229 | # 第二证件 | 241 | # 第二证件 |
230 | second_id_type = order_individual_cus_info.get('secondIdType') | 242 | second_id_type = order_individual_cus_info.get('secondIdType') |
231 | if second_id_type is not None: | 243 | if second_id_type is not None: |
232 | second_ocr_field, second_compare_list = consts.SECOND_ID_TYPE_COMPARE.get(second_id_type) | 244 | if cus_type in consts.NO_COMPARE_CUSTOMER_TYPE or second_id_type not in consts.SECOND_ID_TYPE_COMPARE: |
233 | field_compare(order_individual_cus_info, ocr_res_dict, second_ocr_field, second_compare_list, res_set) | 245 | do_not_compare(order_individual_cus_info, consts.SECOND_ITPRC) |
246 | else: | ||
247 | second_ocr_field, second_compare_list = consts.SECOND_ID_TYPE_COMPARE.get(second_id_type) | ||
248 | field_compare(order_individual_cus_info, ocr_res_dict, second_ocr_field, | ||
249 | second_compare_list, res_set) | ||
234 | # 重新排列 | 250 | # 重新排列 |
235 | new_dict = OrderedDict({}) | 251 | new_dict = OrderedDict({}) |
236 | second_id_res = order_individual_cus_info.pop(consts.SECOND_ID_RES, consts.RESULT_NA) | 252 | second_id_res = order_individual_cus_info.pop(consts.SECOND_ID_RES, consts.RESULT_NA) |
... | @@ -241,10 +257,9 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -241,10 +257,9 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
241 | order_individual_cus_info = new_dict | 257 | order_individual_cus_info = new_dict |
242 | 258 | ||
243 | # sep营业执照 | 259 | # sep营业执照 |
244 | if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]: | 260 | if cus_type == consts.CUSTOMER_TYPE[5]: |
245 | field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set, | 261 | field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set, |
246 | sep_name=sep_name) | 262 | sep_name=sep_name, capital_ignore=True) |
247 | # field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set) | ||
248 | 263 | ||
249 | order_individual_cus_info_list.append(order_individual_cus_info) | 264 | order_individual_cus_info_list.append(order_individual_cus_info) |
250 | 265 | ... | ... |
... | @@ -109,7 +109,7 @@ class Comparison: | ... | @@ -109,7 +109,7 @@ class Comparison: |
109 | if ocr_str == '' or ocr_str.strip() == '': | 109 | if ocr_str == '' or ocr_str.strip() == '': |
110 | return self.RESULT_NA, None | 110 | return self.RESULT_NA, None |
111 | try: | 111 | try: |
112 | ocr_lower = rmb_handler.to_rmb_lower() | 112 | ocr_lower = rmb_handler.to_rmb_lower(ocr_str) |
113 | res = self.build_res(float(input_str) == ocr_lower) | 113 | res = self.build_res(float(input_str) == ocr_lower) |
114 | # input_rmb_upper = to_rmb_upper(float(input_str)) | 114 | # input_rmb_upper = to_rmb_upper(float(input_str)) |
115 | # res = self.build_res(input_rmb_upper == ocr_str) | 115 | # res = self.build_res(input_rmb_upper == ocr_str) | ... | ... |
-
Please register or sign in to post a comment