f4a2c3cb by 周伟奇

add pre id

1 parent 90b2c2a2
...@@ -29,6 +29,8 @@ class Comparison: ...@@ -29,6 +29,8 @@ class Comparison:
29 29
30 self.RESULT_Y = 'Y' 30 self.RESULT_Y = 'Y'
31 self.RESULT_N = 'N' 31 self.RESULT_N = 'N'
32 self.RESULT_N1 = 'N1'
33 self.RESULT_N2 = 'N2'
32 self.RESULT_NA = 'NA' 34 self.RESULT_NA = 'NA'
33 35
34 self.TRANS_MAP = { 36 self.TRANS_MAP = {
...@@ -331,6 +333,26 @@ class Comparison: ...@@ -331,6 +333,26 @@ class Comparison:
331 else: 333 else:
332 return True 334 return True
333 335
336 def is_after_today_pre(self, ocr_str):
337 dt_array, _ = tslib.array_to_datetime(
338 np.array([ocr_str, ], copy=False, dtype=np.object_),
339 errors="coerce",
340 utc=False,
341 dayfirst=False,
342 yearfirst=False,
343 require_iso8601=True,
344 )
345 dti = DatetimeIndex(dt_array, tz=None, name=None)
346 ts = dti[0]
347 if isinstance(ts, NaTType):
348 return self.RESULT_N1
349 elif ts.date() < datetime.today().date():
350 return self.RESULT_N1
351 elif ts.date() > (datetime.today() + relativedelta(days=8)).date():
352 return self.RESULT_Y
353 else:
354 return self.RESULT_N2
355
334 @staticmethod 356 @staticmethod
335 def is_predate_two_year(ocr_str): 357 def is_predate_two_year(ocr_str):
336 dt_array, _ = tslib.array_to_datetime( 358 dt_array, _ = tslib.array_to_datetime(
...@@ -350,7 +372,8 @@ class Comparison: ...@@ -350,7 +372,8 @@ class Comparison:
350 372
351 def se_date_compare(self, input_str, ocr_str, **kwargs): 373 def se_date_compare(self, input_str, ocr_str, **kwargs):
352 if kwargs.get('long', False): 374 if kwargs.get('long', False):
353 if '长期' in ocr_str or '永久' in ocr_str or '***' in ocr_str or '至今' in ocr_str or '年—月—日' in ocr_str or '年 月 日' in ocr_str or '年月日' in ocr_str: 375 if '长期' in ocr_str or '永久' in ocr_str or '***' in ocr_str or '至今' in ocr_str or '年—月—日' in ocr_str \
376 or '年 月 日' in ocr_str or '年月日' in ocr_str:
354 if kwargs.get('today', False) or input_str in ['2099-12-31', '2099-01-01', '2999-12-31', '2999-01-01']: 377 if kwargs.get('today', False) or input_str in ['2099-12-31', '2099-01-01', '2999-12-31', '2999-01-01']:
355 return self.RESULT_Y 378 return self.RESULT_Y
356 else: 379 else:
...@@ -622,6 +645,21 @@ class Comparison: ...@@ -622,6 +645,21 @@ class Comparison:
622 # return self.RESULT_N 645 # return self.RESULT_N
623 # return self.RESULT_N 646 # return self.RESULT_N
624 647
648 # 'long': True, 'ocr_split': True, 'input_replace': '', 'today': True
649 def se_date_compare_pre(self, input_str, ocr_str, **kwargs):
650 if '长期' in ocr_str or '永久' in ocr_str or '***' in ocr_str or '至今' in ocr_str or '年—月—日' in ocr_str \
651 or '年 月 日' in ocr_str or '年月日' in ocr_str:
652 return self.RESULT_Y
653
654 if '至' in ocr_str:
655 ocr_str = ocr_str.split('至')[-1]
656 elif '-' in ocr_str:
657 ocr_str = ocr_str.split('-')[-1]
658
659 # input_str = input_str.replace('-', '')
660
661 return self.is_after_today_pre(ocr_str)
662
625 663
626 cp = Comparison() 664 cp = Comparison()
627 665
......
...@@ -23,8 +23,9 @@ def get_pos_compare_info(pos_info): ...@@ -23,8 +23,9 @@ def get_pos_compare_info(pos_info):
23 for individual_cus_info in individual_cus_info_list: 23 for individual_cus_info in individual_cus_info_list:
24 customer_name = individual_cus_info.get('customerName', '').strip() 24 customer_name = individual_cus_info.get('customerName', '').strip()
25 id_num = individual_cus_info.get('idNum', '') 25 id_num = individual_cus_info.get('idNum', '')
26 applicant_type = individual_cus_info.get('applicantType', '')
26 27
27 if individual_cus_info.get('applicantType', '') == 'CUSTR': 28 if applicant_type == 'CUSTR':
28 custr_name = customer_name 29 custr_name = customer_name
29 custr_id = id_num 30 custr_id = id_num
30 31
...@@ -32,7 +33,9 @@ def get_pos_compare_info(pos_info): ...@@ -32,7 +33,9 @@ def get_pos_compare_info(pos_info):
32 field_input = [(consts.ID_FIELDS[0], customer_name), 33 field_input = [(consts.ID_FIELDS[0], customer_name),
33 (consts.ID_FIELDS[1], id_num), 34 (consts.ID_FIELDS[1], id_num),
34 (consts.ID_FIELDS[2], individual_cus_info.get('idExpiryDate', ''))] 35 (consts.ID_FIELDS[2], individual_cus_info.get('idExpiryDate', ''))]
35 compare_info.setdefault(consts.ID_EN, []).append(field_input) 36 compare_info.setdefault(consts.ID_EN, []).append(
37 (consts.APPLICANT_TYPE_MAP.get(applicant_type, ''), field_input)
38 )
36 39
37 # 新车发票 40 # 新车发票
38 vehicle_info = pos_info.get('vehicleInfo', {}) 41 vehicle_info = pos_info.get('vehicleInfo', {})
...@@ -179,8 +182,8 @@ def pre_compare_process(compare_info, ocr_res_dict, id_res_list): ...@@ -179,8 +182,8 @@ def pre_compare_process(compare_info, ocr_res_dict, id_res_list):
179 compare_result = {} 182 compare_result = {}
180 for license_en, items_list in compare_info.items(): 183 for license_en, items_list in compare_info.items():
181 if license_en == consts.ID_EN: 184 if license_en == consts.ID_EN:
182 for field_list in items_list: 185 for applicant_type, field_list in items_list:
183 result_list = pre_compare_license_id(license_en, id_res_list, field_list) 186 result_list = pre_compare_license_id(license_en, id_res_list, field_list, applicant_type)
184 compare_result.setdefault(license_en, []).append(result_list) 187 compare_result.setdefault(license_en, []).append(result_list)
185 elif license_en in [consts.HIL_CONTRACT_1_EN, consts.HIL_CONTRACT_2_EN, consts.AFC_CONTRACT_EN]: 188 elif license_en in [consts.HIL_CONTRACT_1_EN, consts.HIL_CONTRACT_2_EN, consts.AFC_CONTRACT_EN]:
186 for field_list in items_list: 189 for field_list in items_list:
...@@ -232,7 +235,7 @@ def pre_compare_license(license_en, ocr_res_dict, field_list): ...@@ -232,7 +235,7 @@ def pre_compare_license(license_en, ocr_res_dict, field_list):
232 return result_field_list 235 return result_field_list
233 236
234 237
235 def pre_compare_license_id(license_en, id_res_list, field_list): 238 def pre_compare_license_id(license_en, id_res_list, field_list, applicant_type):
236 ocr_field, compare_logic, no_find_comment = consts.PRE_COMPARE_LOGIC_MAP[license_en] 239 ocr_field, compare_logic, no_find_comment = consts.PRE_COMPARE_LOGIC_MAP[license_en]
237 240
238 is_find = False 241 is_find = False
...@@ -274,22 +277,33 @@ def pre_compare_license_id(license_en, id_res_list, field_list): ...@@ -274,22 +277,33 @@ def pre_compare_license_id(license_en, id_res_list, field_list):
274 break 277 break
275 278
276 # 过期期限特殊处理 279 # 过期期限特殊处理
277 if name == 'idExpiryDate' and result == consts.RESULT_N: 280 # N, N1, N2, Y
281 if name == 'idExpiryDate' and result == consts.RESULT_N: # 遍历所有背面过期时间
278 if len(expiry_dates) == 0: 282 if len(expiry_dates) == 0:
283 result = consts.RESULT_N1
279 ocr_str = empty_str 284 ocr_str = empty_str
280 result = consts.RESULT_N
281 else: 285 else:
286 tmp_res_set = set()
282 for expiry_date in expiry_dates: 287 for expiry_date in expiry_dates:
283 expiry_date_res = getattr(cp, compare_logic[name][1])(value, expiry_date, 288 expiry_date_res = getattr(cp, compare_logic[name][1])(value, expiry_date,
284 **compare_logic[name][2]) 289 **compare_logic[name][2])
285 if expiry_date_res == consts.RESULT_N: 290 tmp_res_set.add(expiry_date_res)
291 if expiry_date_res == consts.RESULT_N1:
292 result = expiry_date_res
286 ocr_str = expiry_date 293 ocr_str = expiry_date
287 break 294 break
288 else: 295 else:
289 ocr_str = empty_str 296 ocr_str = empty_str
297 if consts.RESULT_N2 in tmp_res_set:
298 result = consts.RESULT_N2
299 else:
290 result = consts.RESULT_Y 300 result = consts.RESULT_Y
291 301
292 if ca_or_se_idx == 0 and result == consts.RESULT_N: 302 if ca_or_se_idx == 0:
303 if name == 'idExpiryDate':
304 if result == consts.RESULT_N or result == consts.RESULT_N1:
305 break
306 elif result == consts.RESULT_N:
293 break 307 break
294 308
295 if ca_or_se_idx == 1: 309 if ca_or_se_idx == 1:
...@@ -299,10 +313,12 @@ def pre_compare_license_id(license_en, id_res_list, field_list): ...@@ -299,10 +313,12 @@ def pre_compare_license_id(license_en, id_res_list, field_list):
299 313
300 if isinstance(value, list): 314 if isinstance(value, list):
301 value = json.dumps(value, ensure_ascii=False) 315 value = json.dumps(value, ensure_ascii=False)
302 result_field_list.append((value, ocr_str, result, compare_logic[name][3])) 316
317 comments = consts.ID_DATE_MAP[result] if name == 'idExpiryDate' else compare_logic[name][3]
318 result_field_list.append((value, ocr_str, result, '{0}{1}'.format(applicant_type, comments)))
303 319
304 if not is_find: 320 if not is_find:
305 result_field_list = [(empty_str, empty_str, consts.RESULT_N, no_find_comment)] 321 result_field_list = [(empty_str, empty_str, consts.RESULT_N, '{0}{1}'.format(applicant_type, no_find_comment))]
306 322
307 return result_field_list 323 return result_field_list
308 324
...@@ -377,7 +393,7 @@ def rebuild_result(compare_result): ...@@ -377,7 +393,7 @@ def rebuild_result(compare_result):
377 for result_field_list in items_list: 393 for result_field_list in items_list:
378 field_list = [] 394 field_list = []
379 for input_str, ocr_str, result, comments in result_field_list: 395 for input_str, ocr_str, result, comments in result_field_list:
380 if result == consts.RESULT_N: 396 if result != consts.RESULT_Y:
381 is_pass = False 397 is_pass = False
382 field_list.append( 398 field_list.append(
383 { 399 {
......
...@@ -112,6 +112,13 @@ HT_COMPARE_LOGIC = { ...@@ -112,6 +112,13 @@ HT_COMPARE_LOGIC = {
112 AFC_CON_FIELDS[9]: ('ASP项目详情', 'se_asp_compare', {}, '合同ASP名称或者金额与系统不一致'), 112 AFC_CON_FIELDS[9]: ('ASP项目详情', 'se_asp_compare', {}, '合同ASP名称或者金额与系统不一致'),
113 } 113 }
114 114
115 ID_COMPARE_LOGIC = {
116 'customerName': ('姓名', 'se_name_compare', {}, '身份证姓名与系统不一致'),
117 'idNum': ('公民身份号码', 'se_common_compare', {}, '身份证号码与系统不一致'),
118
119 'idExpiryDate': ('有效期限', 'se_date_compare_pre', {}, '身份证有效期疑似过期'),
120 }
121
115 PRE_COMPARE_LOGIC_MAP = { 122 PRE_COMPARE_LOGIC_MAP = {
116 ID_EN: (ID_OCR_FIELD, ID_COMPARE_LOGIC, '请确认是否提供身份证件'), 123 ID_EN: (ID_OCR_FIELD, ID_COMPARE_LOGIC, '请确认是否提供身份证件'),
117 MVI_EN: (MVI_OCR_FIELD, MVI_COMPARE_LOGIC, '请确认是否提供发票'), 124 MVI_EN: (MVI_OCR_FIELD, MVI_COMPARE_LOGIC, '请确认是否提供发票'),
...@@ -125,4 +132,19 @@ PRE_COMPARE_LOGIC_MAP = { ...@@ -125,4 +132,19 @@ PRE_COMPARE_LOGIC_MAP = {
125 132
126 RESULT_Y = 'Y' 133 RESULT_Y = 'Y'
127 RESULT_N = 'N' 134 RESULT_N = 'N'
135 RESULT_N1 = 'N1'
136 RESULT_N2 = 'N2'
137
138 ID_DATE_MAP = {
139 RESULT_N: '身份证有效期疑似过期',
140 RESULT_Y: '身份证有效期疑似过期',
141 RESULT_N1: '身份证有效期疑似过期',
142 RESULT_N2: '身份证即将过期,请尽快提交放款申请',
143 }
128 144
145 APPLICANT_TYPE_MAP = {
146 'CUSTR': 'Applicant',
147 'COAPP': 'Co Applicant',
148 'GAUTR1': 'guarantor1',
149 'GAUTR2': 'guarantor2',
150 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!