582db5c6 by 周伟奇

fix bug

1 parent bf81e885
...@@ -1138,7 +1138,7 @@ TCCOR = [ ...@@ -1138,7 +1138,7 @@ TCCOR = [
1138 ('taxRegistrationCode', '注册号', 'common_compare', {}, 'taxRegistrationCodeResult'), 1138 ('taxRegistrationCode', '注册号', 'common_compare', {}, 'taxRegistrationCodeResult'),
1139 ('incorporationDate', '成立日期', 'date_compare', {'ocr_replace': True}, 'incorporationDateResult'), # 2017年07月11日 1139 ('incorporationDate', '成立日期', 'date_compare', {'ocr_replace': True}, 'incorporationDateResult'), # 2017年07月11日
1140 # 2017年07月11日至长期 1. OCR识别为长期,向GCAP发送:2099-12-31 00:00:00.0 1140 # 2017年07月11日至长期 1. OCR识别为长期,向GCAP发送:2099-12-31 00:00:00.0
1141 ('businessLicenseDueDate', '营业期限', 'date_compare', {'long': True, 'ocr_replace': True}, 'businessLicenseDueDateResult'), 1141 ('businessLicenseDueDate', '营业期限', 'date_compare', {'ocr_split': True, 'long': True, 'ocr_replace': True}, 'businessLicenseDueDateResult'),
1142 ('capitalRegAmount', '注册资本', 'rmb_compare', {}, 'capitalRegAmountResult'), # 壹拾万元整 将OCR识别结果(人民币大写)转化为数字 1142 ('capitalRegAmount', '注册资本', 'rmb_compare', {}, 'capitalRegAmountResult'), # 壹拾万元整 将OCR识别结果(人民币大写)转化为数字
1143 ] 1143 ]
1144 1144
......
...@@ -24,12 +24,22 @@ def get_order_dict(src_dict, order_tuple): ...@@ -24,12 +24,22 @@ def get_order_dict(src_dict, order_tuple):
24 return order_dict 24 return order_dict
25 25
26 26
27 def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set): 27 def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has_expiry_date=False):
28 is_find = False 28 is_find = False
29 ocr_res_str = ocr_res_dict.get(ocr_field) 29 ocr_res_str = ocr_res_dict.get(ocr_field)
30 if ocr_res_str is not None: 30 if ocr_res_str is not None:
31 ocr_res_list = json.loads(ocr_res_str) 31 ocr_res_list = json.loads(ocr_res_str)
32 # res_len = len(ocr_res_list) 32
33 # 过期期限特殊处理
34 if has_expiry_date:
35 expiry_dates = []
36 key = compare_list[2][1]
37 for ocr_res in ocr_res_list:
38 if ocr_res.get(key):
39 expiry_dates.append(ocr_res.get(key))
40 else:
41 expiry_dates = []
42
33 for ocr_res in ocr_res_list: 43 for ocr_res in ocr_res_list:
34 if is_find: 44 if is_find:
35 break 45 break
...@@ -42,6 +52,20 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set): ...@@ -42,6 +52,20 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set):
42 if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA]: 52 if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA]:
43 break 53 break
44 is_find = True 54 is_find = True
55
56 # 过期期限特殊处理
57 if idx == 2 and has_expiry_date:
58 if compare_res == consts.RESULT_NA:
59 for expiry_date in expiry_dates:
60 expiry_date_compare_res, expiry_date_ocr_output = getattr(cp, compare_tuple[2])(
61 input_str, expiry_date, idx, **compare_tuple[3]
62 )
63 if expiry_date_compare_res == consts.RESULT_Y:
64 compare_res = consts.RESULT_Y
65 ocr_output = expiry_date_ocr_output
66 ocr_str = expiry_date
67 break
68
45 info_dict[compare_tuple[4]] = compare_res 69 info_dict[compare_tuple[4]] = compare_res
46 if input_str is not None: 70 if input_str is not None:
47 if ocr_str is None or ocr_output is None: 71 if ocr_str is None or ocr_output is None:
...@@ -151,7 +175,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id): ...@@ -151,7 +175,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
151 id_type = order_individual_cus_info.get('idType') 175 id_type = order_individual_cus_info.get('idType')
152 compare_info_list = consts.ID_TYPE_COMPARE.get(id_type) 176 compare_info_list = consts.ID_TYPE_COMPARE.get(id_type)
153 if compare_info_list is not None: 177 if compare_info_list is not None:
154 field_compare(order_individual_cus_info, ocr_res_dict, compare_info_list[0], compare_info_list[1], res_set) 178 field_compare(order_individual_cus_info, ocr_res_dict, compare_info_list[0], compare_info_list[1], res_set, has_expiry_date=True)
155 179
156 # 第二证件 180 # 第二证件
157 second_id_type = order_individual_cus_info.get('secondIdType') 181 second_id_type = order_individual_cus_info.get('secondIdType')
......
...@@ -78,6 +78,9 @@ class Comparison: ...@@ -78,6 +78,9 @@ class Comparison:
78 if kwargs.get('long', False) and '长期' in ocr_str: 78 if kwargs.get('long', False) and '长期' in ocr_str:
79 return self.RESULT_Y, '2099-12-31' 79 return self.RESULT_Y, '2099-12-31'
80 if kwargs.get('ocr_split', False): 80 if kwargs.get('ocr_split', False):
81 if '至' in ocr_str:
82 ocr_str = ocr_str.split('至')[-1]
83 elif '-' in ocr_str:
81 ocr_str = ocr_str.split('-')[-1] 84 ocr_str = ocr_str.split('-')[-1]
82 if kwargs.get('ocr_replace', False): 85 if kwargs.get('ocr_replace', False):
83 ocr_str = ocr_str.replace('年', '-').replace('月', '-').replace('日', '') 86 ocr_str = ocr_str.replace('年', '-').replace('月', '-').replace('日', '')
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!