fix vino
Showing
2 changed files
with
26 additions
and
24 deletions
... | @@ -1163,5 +1163,8 @@ UC_ORDER = ('vinNo', 'manufactureDate', 'firstRegistrationDate') | ... | @@ -1163,5 +1163,8 @@ UC_ORDER = ('vinNo', 'manufactureDate', 'firstRegistrationDate') |
1163 | CO_ORDER = ('customerType', 'customerChineseName', 'legalRepName', 'idNum', 'businessLicenseNo', 'taxRegistrationCode', | 1163 | CO_ORDER = ('customerType', 'customerChineseName', 'legalRepName', 'idNum', 'businessLicenseNo', 'taxRegistrationCode', |
1164 | 'incorporationDate', 'businessLicenseDueDate', 'capitalRegAmount') | 1164 | 'incorporationDate', 'businessLicenseDueDate', 'capitalRegAmount') |
1165 | 1165 | ||
1166 | PREFIX_MVC = 'GB' | ||
1167 | PREFIX_DL = 'DL' | ||
1168 | |||
1166 | 1169 | ||
1167 | 1170 | ... | ... |
... | @@ -49,14 +49,13 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has | ... | @@ -49,14 +49,13 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has |
49 | ocr_str = ocr_res.get(compare_tuple[1]) | 49 | ocr_str = ocr_res.get(compare_tuple[1]) |
50 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( | 50 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( |
51 | input_str, ocr_str, idx, **compare_tuple[3]) | 51 | input_str, ocr_str, idx, **compare_tuple[3]) |
52 | print('type: {0}, idx: {1}, field: {2}, input: {3}, ocr: {4}, res: {5}, out: {6}'.format(ocr_field, idx, compare_tuple[0], input_str, ocr_str, compare_res, ocr_output)) | 52 | # print('type: {0}, idx: {1}, field: {2}, input: {3}, ocr: {4}, res: {5}, out: {6}'.format(ocr_field, idx, compare_tuple[0], input_str, ocr_str, compare_res, ocr_output)) |
53 | if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA] and length > 1: | 53 | if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA] and length > 1: |
54 | break | 54 | break |
55 | is_find = True | 55 | is_find = True |
56 | 56 | ||
57 | # 过期期限特殊处理 | 57 | # 过期期限特殊处理 |
58 | if idx == 2 and has_expiry_date: | 58 | if idx == 2 and has_expiry_date and compare_res == consts.RESULT_NA: |
59 | if compare_res == consts.RESULT_NA: | ||
60 | for expiry_date in expiry_dates: | 59 | for expiry_date in expiry_dates: |
61 | expiry_date_compare_res, expiry_date_ocr_output = getattr(cp, compare_tuple[2])( | 60 | expiry_date_compare_res, expiry_date_ocr_output = getattr(cp, compare_tuple[2])( |
62 | input_str, expiry_date, idx, **compare_tuple[3] | 61 | input_str, expiry_date, idx, **compare_tuple[3] |
... | @@ -90,17 +89,16 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s | ... | @@ -90,17 +89,16 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s |
90 | if ocr_res_str is not None: | 89 | if ocr_res_str is not None: |
91 | ocr_res_list = json.loads(ocr_res_str) | 90 | ocr_res_list = json.loads(ocr_res_str) |
92 | 91 | ||
93 | # 车辆登记证3、4页去除 | 92 | # 3、4页/副页去除 |
94 | if ocr_field == consts.MVC_OCR_FIELD: | 93 | # if ocr_field == consts.MVC_OCR_FIELD: |
95 | tmp_list = [] | 94 | tmp_list = [] |
96 | for res in ocr_res_list: | 95 | for res in ocr_res_list: |
97 | if res.get(compare_list[0][1]) is not None: | 96 | if res.get(compare_list[0][1]) is not None: |
98 | tmp_list.append(res) | 97 | tmp_list.append(res) |
99 | ocr_res_list = tmp_list | ||
100 | 98 | ||
101 | length = len(ocr_res_list) | 99 | length = len(tmp_list) |
102 | 100 | ||
103 | for ocr_res in ocr_res_list: | 101 | for ocr_res in tmp_list: |
104 | if is_find: | 102 | if is_find: |
105 | break | 103 | break |
106 | for idx, compare_tuple in enumerate(compare_list): | 104 | for idx, compare_tuple in enumerate(compare_list): |
... | @@ -108,7 +106,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s | ... | @@ -108,7 +106,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s |
108 | ocr_str = ocr_res.get(compare_tuple[1]) | 106 | ocr_str = ocr_res.get(compare_tuple[1]) |
109 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( | 107 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( |
110 | input_str, ocr_str, idx, **compare_tuple[3]) | 108 | input_str, ocr_str, idx, **compare_tuple[3]) |
111 | print('type: {0}, idx: {1}, field: {2}, input: {3}, ocr: {4}, res: {5}, out: {6}'.format(ocr_field, idx, compare_tuple[0], input_str, ocr_str, compare_res, ocr_output)) | 109 | # print('type: {0}, idx: {1}, field: {2}, input: {3}, ocr: {4}, res: {5}, out: {6}'.format(ocr_field, idx, compare_tuple[0], input_str, ocr_str, compare_res, ocr_output)) |
112 | if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA]: | 110 | if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA]: |
113 | if ocr_str is not None: | 111 | if ocr_str is not None: |
114 | no_match_vino.append(ocr_str) | 112 | no_match_vino.append(ocr_str) |
... | @@ -226,21 +224,22 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -226,21 +224,22 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
226 | dl_find, dl_vinos = usedcar_info_compare(order_usedcar_info, ocr_res_dict, consts.DL_OCR_FIELD, consts.PCUSD_DL, res_set) | 224 | dl_find, dl_vinos = usedcar_info_compare(order_usedcar_info, ocr_res_dict, consts.DL_OCR_FIELD, consts.PCUSD_DL, res_set) |
227 | 225 | ||
228 | if mvc_find is True and dl_find is False: | 226 | if mvc_find is True and dl_find is False: |
229 | vino = dl_vinos[0] if len(dl_vinos) > 0 else '' | 227 | vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' |
230 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino | 228 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}: {1}'.format(consts.PREFIX_MVC, vino) |
231 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | 229 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N |
232 | elif mvc_find is False and dl_find is True: | 230 | elif mvc_find is False and dl_find is True: |
233 | vino = mvc_vinos[0] if len(mvc_vinos) > 0 else '' | 231 | vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' |
234 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino | 232 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}: {1}'.format(consts.PREFIX_DL, vino) |
235 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | 233 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N |
236 | elif mvc_find is False and dl_find is False: | 234 | elif mvc_find is False and dl_find is False: |
237 | vino_list = [] | 235 | vino_list = [] |
238 | if len(mvc_vinos) > 0: | 236 | mvc_vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else '' |
239 | vino_list.append(mvc_vinos[0]) | 237 | dl_vino = dl_vinos[-1] if len(dl_vinos) > 0 else '' |
240 | if len(dl_vinos) > 0: | 238 | vino_list.append('{0}: {1}'.format(consts.PREFIX_MVC, mvc_vino)) |
241 | vino_list.append(dl_vinos[0]) | 239 | vino_list.append(dl_vinos[-1]) |
242 | vino = '、'.join(vino_list) | 240 | vino = '、'.join('{0}: {1}'.format(consts.PREFIX_DL, dl_vino)) |
243 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino | 241 | order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino |
242 | order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N | ||
244 | 243 | ||
245 | comparison_res['OCR_Input']['usedCarInfo'] = order_usedcar_info | 244 | comparison_res['OCR_Input']['usedCarInfo'] = order_usedcar_info |
246 | 245 | ||
... | @@ -262,6 +261,12 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -262,6 +261,12 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
262 | '[compare_res={5}]'.format(log_base, application_entity, application_id, uniq_seq, | 261 | '[compare_res={5}]'.format(log_base, application_entity, application_id, uniq_seq, |
263 | ocr_res_id, comparison_res)) | 262 | ocr_res_id, comparison_res)) |
264 | 263 | ||
264 | is_gcap_send = Configs.objects.filter(id=1).first() | ||
265 | if is_gcap_send is not None and is_gcap_send.value == 'N': | ||
266 | compare_log.info('{0} [gcap closed] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | ||
267 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | ||
268 | return | ||
269 | |||
265 | # 时间延迟 | 270 | # 时间延迟 |
266 | send_time = last_obj.create_time + timedelta(seconds=15) | 271 | send_time = last_obj.create_time + timedelta(seconds=15) |
267 | while datetime.now() < send_time: | 272 | while datetime.now() < send_time: |
... | @@ -269,12 +274,6 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): | ... | @@ -269,12 +274,6 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): |
269 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | 274 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) |
270 | time.sleep(5) | 275 | time.sleep(5) |
271 | 276 | ||
272 | is_gcap_send = Configs.objects.filter(id=1).first() | ||
273 | if is_gcap_send is not None and is_gcap_send.value == 'N': | ||
274 | compare_log.info('{0} [gcap closed] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'.format( | ||
275 | log_base, application_entity, application_id, uniq_seq, ocr_res_id)) | ||
276 | return | ||
277 | |||
278 | # 将比对结果发送GCAP | 277 | # 将比对结果发送GCAP |
279 | try: | 278 | try: |
280 | data = gcap.dict_to_xml(comparison_res) | 279 | data = gcap.dict_to_xml(comparison_res) | ... | ... |
-
Please register or sign in to post a comment