ca compare fix back
Showing
2 changed files
with
63 additions
and
38 deletions
... | @@ -30,30 +30,33 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has | ... | @@ -30,30 +30,33 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has |
30 | ocr_res_str = ocr_res_dict.get(ocr_field) | 30 | ocr_res_str = ocr_res_dict.get(ocr_field) |
31 | if ocr_res_str is not None: | 31 | if ocr_res_str is not None: |
32 | ocr_res_list = json.loads(ocr_res_str) | 32 | ocr_res_list = json.loads(ocr_res_str) |
33 | 33 | length = len(ocr_res_list) | |
34 | # sep营业执照根据法人过滤 | 34 | |
35 | if isinstance(sep_name, str): | 35 | # # sep营业执照根据法人过滤 |
36 | tmp_list = [] | 36 | # if isinstance(sep_name, str): |
37 | for ocr_res in ocr_res_list: | 37 | # tmp_list = [] |
38 | ocr_sep_name = ocr_res.get(consts.LEGAL_REP_NAME) | 38 | # for ocr_res in ocr_res_list: |
39 | if isinstance(ocr_sep_name, str) and ocr_sep_name == sep_name: | 39 | # ocr_sep_name = ocr_res.get(consts.LEGAL_REP_NAME) |
40 | tmp_list.append(ocr_res) | 40 | # if isinstance(ocr_sep_name, str) and ocr_sep_name == sep_name: |
41 | else: | 41 | # tmp_list.append(ocr_res) |
42 | tmp_list = ocr_res_list | 42 | # else: |
43 | 43 | # tmp_list = ocr_res_list | |
44 | length = len(tmp_list) | 44 | # |
45 | # length = len(tmp_list) | ||
45 | 46 | ||
46 | # 过期期限特殊处理 | 47 | # 过期期限特殊处理 |
47 | if has_expiry_date: | 48 | if has_expiry_date: |
48 | expiry_dates = [] | 49 | expiry_dates = [] |
49 | key = compare_list[2][1] | 50 | key = compare_list[2][1] |
50 | for ocr_res in tmp_list: | 51 | # for ocr_res in tmp_list: |
52 | for ocr_res in ocr_res_list: | ||
51 | if ocr_res.get(key): | 53 | if ocr_res.get(key): |
52 | expiry_dates.append(ocr_res.get(key)) | 54 | expiry_dates.append(ocr_res.get(key)) |
53 | else: | 55 | else: |
54 | expiry_dates = [] | 56 | expiry_dates = [] |
55 | 57 | ||
56 | for ocr_res in tmp_list: | 58 | # for ocr_res in tmp_list: |
59 | for ocr_res in ocr_res_list: | ||
57 | if is_find: | 60 | if is_find: |
58 | break | 61 | break |
59 | for idx, compare_tuple in enumerate(compare_list): | 62 | for idx, compare_tuple in enumerate(compare_list): |
... | @@ -201,15 +204,15 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -201,15 +204,15 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
201 | for individual_cus_info in individual_cus_info_list: | 204 | for individual_cus_info in individual_cus_info_list: |
202 | order_individual_cus_info = get_order_dict(individual_cus_info, consts.IN_ORDER) | 205 | order_individual_cus_info = get_order_dict(individual_cus_info, consts.IN_ORDER) |
203 | 206 | ||
204 | # 获取sep下营业执照法人代表 | 207 | # # 获取sep下营业执照法人代表 |
205 | if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]: | 208 | # if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]: |
206 | sep_name = order_individual_cus_info.get('customerChineseName') | 209 | # sep_name = order_individual_cus_info.get('customerChineseName') |
207 | if isinstance(sep_name, str): | 210 | # if isinstance(sep_name, str): |
208 | sep_name = sep_name.strip() | 211 | # sep_name = sep_name.strip() |
209 | if sep_name == '': | 212 | # if sep_name == '': |
210 | sep_name = None | 213 | # sep_name = None |
211 | else: | 214 | # else: |
212 | sep_name = None | 215 | # sep_name = None |
213 | 216 | ||
214 | # 个人信息证件 | 217 | # 个人信息证件 |
215 | id_type = order_individual_cus_info.get('idType') | 218 | id_type = order_individual_cus_info.get('idType') |
... | @@ -235,8 +238,9 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -235,8 +238,9 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
235 | 238 | ||
236 | # sep营业执照 | 239 | # sep营业执照 |
237 | if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]: | 240 | if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]: |
238 | field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set, | 241 | # field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set, |
239 | sep_name=sep_name) | 242 | # sep_name=sep_name) |
243 | field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set) | ||
240 | 244 | ||
241 | order_individual_cus_info_list.append(order_individual_cus_info) | 245 | order_individual_cus_info_list.append(order_individual_cus_info) |
242 | 246 | ||
... | @@ -253,21 +257,38 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -253,21 +257,38 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
253 | dl_find, dl_vinos = usedcar_info_compare(order_usedcar_info, ocr_res_dict, consts.DL_OCR_FIELD, | 257 | dl_find, dl_vinos = usedcar_info_compare(order_usedcar_info, ocr_res_dict, consts.DL_OCR_FIELD, |
254 | consts.PCUSD_DL, res_set) | 258 | consts.PCUSD_DL, res_set) |
255 | 259 | ||
260 | # if mvc_find is True and dl_find is False: | ||
261 | # vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' | ||
262 | # order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}: {1}'.format(consts.PREFIX_MVC, vino) | ||
263 | # order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | ||
264 | # elif mvc_find is False and dl_find is True: | ||
265 | # vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' | ||
266 | # order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}: {1}'.format(consts.PREFIX_DL, vino) | ||
267 | # order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | ||
268 | # elif mvc_find is False and dl_find is False: | ||
269 | # vino_list = [] | ||
270 | # mvc_vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' | ||
271 | # dl_vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' | ||
272 | # vino_list.append('{0}: {1}'.format(consts.PREFIX_MVC, mvc_vino)) | ||
273 | # vino_list.append(dl_vinos[-1]) | ||
274 | # vino = '、'.join('{0}: {1}'.format(consts.PREFIX_DL, dl_vino)) | ||
275 | # order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino | ||
276 | |||
256 | if mvc_find is True and dl_find is False: | 277 | if mvc_find is True and dl_find is False: |
257 | vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' | 278 | vino = dl_vinos[0] if len(dl_vinos) > 0 else '' |
258 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}: {1}'.format(consts.PREFIX_MVC, vino) | 279 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino |
259 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | 280 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N |
260 | elif mvc_find is False and dl_find is True: | 281 | elif mvc_find is False and dl_find is True: |
261 | vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' | 282 | vino = mvc_vinos[0] if len(mvc_vinos) > 0 else '' |
262 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}: {1}'.format(consts.PREFIX_DL, vino) | 283 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino |
263 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | 284 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N |
264 | elif mvc_find is False and dl_find is False: | 285 | elif mvc_find is False and dl_find is False: |
265 | vino_list = [] | 286 | vino_list = [] |
266 | mvc_vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' | 287 | if len(mvc_vinos) > 0: |
267 | dl_vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' | 288 | vino_list.append(mvc_vinos[0]) |
268 | vino_list.append('{0}: {1}'.format(consts.PREFIX_MVC, mvc_vino)) | 289 | if len(dl_vinos) > 0: |
269 | vino_list.append(dl_vinos[-1]) | 290 | vino_list.append(dl_vinos[0]) |
270 | vino = '、'.join('{0}: {1}'.format(consts.PREFIX_DL, dl_vino)) | 291 | vino = '、'.join(vino_list) |
271 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino | 292 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino |
272 | 293 | ||
273 | comparison_res['OCR_Input']['usedCarInfo'] = order_usedcar_info | 294 | comparison_res['OCR_Input']['usedCarInfo'] = order_usedcar_info | ... | ... |
1 | import re | 1 | import re |
2 | from datetime import datetime | 2 | from datetime import datetime |
3 | from .rmb_lower import rmb_handler | 3 | # from .rmb_lower import rmb_handler |
4 | from .rmb_upper import to_rmb_upper | ||
4 | 5 | ||
5 | 6 | ||
6 | class Comparison: | 7 | class Comparison: |
... | @@ -108,15 +109,18 @@ class Comparison: | ... | @@ -108,15 +109,18 @@ class Comparison: |
108 | if ocr_str == '' or ocr_str.strip() == '': | 109 | if ocr_str == '' or ocr_str.strip() == '': |
109 | return self.RESULT_NA, None | 110 | return self.RESULT_NA, None |
110 | try: | 111 | try: |
111 | ocr_lower = rmb_handler.to_rmb_lower() | 112 | # ocr_lower = rmb_handler.to_rmb_lower() |
112 | 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)) | ||
115 | res = self.build_res(input_rmb_upper == ocr_str) | ||
113 | except Exception as e: | 116 | except Exception as e: |
114 | return self.RESULT_N, None | 117 | return self.RESULT_N, None |
115 | else: | 118 | else: |
116 | if res == self.RESULT_Y: | 119 | if res == self.RESULT_Y: |
117 | return res, input_str | 120 | return res, input_str |
118 | else: | 121 | else: |
119 | return res, ocr_lower | 122 | # return res, ocr_lower |
123 | return res, None | ||
120 | 124 | ||
121 | def type_compare(self, input_str, ocr_str, idx, **kwargs): | 125 | def type_compare(self, input_str, ocr_str, idx, **kwargs): |
122 | if not isinstance(ocr_str, str) or not isinstance(input_str, str): | 126 | if not isinstance(ocr_str, str) or not isinstance(input_str, str): | ... | ... |
-
Please register or sign in to post a comment