se compare part 7
Showing
2 changed files
with
116 additions
and
104 deletions
... | @@ -1260,6 +1260,8 @@ SE_CORPORATE_ALL_FIELD = ['companyName', 'legalRepName', 'firstIdNo', 'businessL | ... | @@ -1260,6 +1260,8 @@ SE_CORPORATE_ALL_FIELD = ['companyName', 'legalRepName', 'firstIdNo', 'businessL |
1260 | SE_NEW_FIELD = ['vinNo', 'dealer', 'vehicleTransactionAmount'] | 1260 | SE_NEW_FIELD = ['vinNo', 'dealer', 'vehicleTransactionAmount'] |
1261 | SE_USED_FIELD = ['vinNo', 'vehicleTransactionAmount'] | 1261 | SE_USED_FIELD = ['vinNo', 'vehicleTransactionAmount'] |
1262 | SE_NEW_ADD_FIELD = ['customerName', 'idNum', 'dateOfInvoice'] | 1262 | SE_NEW_ADD_FIELD = ['customerName', 'idNum', 'dateOfInvoice'] |
1263 | SE_GB_NEW_FIELD = ['vinNo'] | ||
1264 | SE_GB_USED_FIELD = ['customerName', 'idNum', 'date'] | ||
1263 | 1265 | ||
1264 | SE_BANK_FIELD = ['accountNo', 'bankName'] | 1266 | SE_BANK_FIELD = ['accountNo', 'bankName'] |
1265 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] | 1267 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] |
... | @@ -1274,89 +1276,93 @@ RP_EN = 'Resident ID' | ... | @@ -1274,89 +1276,93 @@ RP_EN = 'Resident ID' |
1274 | BL_EN = 'Business permit' | 1276 | BL_EN = 'Business permit' |
1275 | MVI_EN = 'newCar Invoice' | 1277 | MVI_EN = 'newCar Invoice' |
1276 | UCI_EN = 'usedCar Invoice' | 1278 | UCI_EN = 'usedCar Invoice' |
1279 | MVC_EN = 'Green Book' | ||
1277 | BC_EN = 'Bank Card' | 1280 | BC_EN = 'Bank Card' |
1278 | DDA_EN = 'DDA' | 1281 | DDA_EN = 'DDA' |
1279 | 1282 | ||
1280 | ID_COMPARE_LOGIC = [ | 1283 | ID_COMPARE_LOGIC = { |
1281 | ('customerName', '姓名'), | 1284 | 'customerName': ('姓名', ), |
1282 | ('idNum', '公民身份号码'), | 1285 | 'idNum': ('公民身份号码', ), |
1283 | ('dateOfBirth', '出生年月'), | 1286 | 'dateOfBirth': ('出生年月', ), |
1284 | ('idExpiryDate', '有效期限'), | 1287 | 'idExpiryDate': ('有效期限', ), |
1285 | ('hukouProvince', '住址'), | 1288 | 'hukouProvince': ('住址', ), |
1286 | ('hukouCity', '住址'), | 1289 | 'hukouCity': ('住址', ), |
1287 | ] | 1290 | } |
1288 | |||
1289 | PP_COMPARE_LOGIC = [ | ||
1290 | ('customerName', '英文姓名'), | ||
1291 | ('idNum', '护照号码'), | ||
1292 | ('dateOfBirth', '出生日期'), | ||
1293 | ('idExpiryDate', '有效期至'), | ||
1294 | ] | ||
1295 | 1291 | ||
1296 | EEP_COMPARE_LOGIC = [ | 1292 | PP_COMPARE_LOGIC = { |
1297 | ('customerName', '中文名'), | 1293 | 'customerName': ('英文姓名', ), |
1298 | ('idNum', '证件号码'), | 1294 | 'idNum': ('护照号码', ), |
1299 | ('dateOfBirth', '出生日期'), | 1295 | 'dateOfBirth': ('出生日期', ), |
1300 | ('idExpiryDate', '有效期限'), | 1296 | 'idExpiryDate': ('有效期至', ), |
1301 | ] | 1297 | } |
1302 | 1298 | ||
1303 | RP_COMPARE_LOGIC = [ | 1299 | EEP_COMPARE_LOGIC = { |
1304 | ('customerName', '姓名'), | 1300 | 'customerName': ('中文名', ), |
1305 | ('idNum', '公民身份号码'), | 1301 | 'idNum': ('证件号码', ), |
1306 | ('dateOfBirth', '出生年月'), | 1302 | 'dateOfBirth': ('出生日期', ), |
1307 | ('idExpiryDate', '有效期限'), | 1303 | 'idExpiryDate': ('有效期限', ), |
1308 | ('hukouProvince', '住址'), | 1304 | } |
1309 | ('hukouCity', '住址'), | ||
1310 | ] | ||
1311 | 1305 | ||
1312 | BL_COMPARE_LOGIC = [ | 1306 | RP_COMPARE_LOGIC = { |
1313 | ('companyName', '企业名称', ), | 1307 | 'customerName': ('姓名', ), |
1314 | ('legalRepName', '经营者姓名', ), | 1308 | 'idNum': ('公民身份号码', ), |
1315 | ('firstIdNo', '注册号', ), | 1309 | 'dateOfBirth': ('出生年月', ), |
1316 | ('businessLicenseNo', '注册号', ), | 1310 | 'idExpiryDate': ('有效期限', ), |
1317 | ('organizationCreditCode', '注册号', ), | 1311 | 'hukouProvince': ('住址', ), |
1318 | ('taxRegistrationCertificateNo', '注册号', ), | 1312 | 'hukouCity': ('住址', ), |
1319 | ('establishmentDate', '成立日期', ), # 2017年07月11日 | 1313 | } |
1320 | # 2017年07月11日至长期 1. OCR识别为长期,向GCAP发送:2099-12-31 00:00:00.0 | ||
1321 | ('businessLicenseDueDate', '营业期限'), | ||
1322 | ('organizationType', '企业类型', ), # 有限责任公司 | ||
1323 | ('registeredCapital', '注册资本', ), # 壹拾万元整 将OCR识别结果(人民币大写)转化为数字 | ||
1324 | ] | ||
1325 | 1314 | ||
1326 | MVI_COMPARE_LOGIC = [ | 1315 | BL_COMPARE_LOGIC = { |
1327 | ('vinNo', '车辆识别代码'), | 1316 | 'companyName': ('企业名称', ), |
1328 | ('dealer', '销方名称'), | 1317 | 'legalRepName': ('经营者姓名', ), |
1329 | ('vehicleTransactionAmount', '价税合计小写'), | 1318 | 'firstIdNo': ('注册号', ), |
1330 | ('customerName', '购方名称'), | 1319 | 'businessLicenseNo': ('注册号', ), |
1331 | ('idNum', '购买方身份证号或组织机构代码'), | 1320 | 'organizationCreditCode': ('注册号', ), |
1332 | ('dateOfInvoice', '开票日期'), | 1321 | 'taxRegistrationCertificateNo': ('注册号', ), |
1333 | ] | 1322 | 'establishmentDate': ('成立日期', ), |
1323 | 'businessLicenseDueDate': ('营业期限', ), | ||
1324 | 'organizationType': ('企业类型', ), | ||
1325 | 'registeredCapital': ('注册资本', ), | ||
1326 | } | ||
1334 | 1327 | ||
1335 | UCI_COMPARE_LOGIC = [ | 1328 | MVI_COMPARE_LOGIC = { |
1336 | ('vinNo', '车架号'), | 1329 | 'vinNo': ('车辆识别代码', ), |
1337 | ('vehicleTransactionAmount', '价税合计小写'), | 1330 | 'dealer': ('销方名称', ), |
1338 | ('customerName', '购方名称'), | 1331 | 'vehicleTransactionAmount': ('价税合计小写', ), |
1339 | ('idNum', '购方纳税人识别号'), | 1332 | 'customerName': ('购方名称', ), |
1340 | ] | 1333 | 'idNum': ('购买方身份证号或组织机构代码', ), |
1334 | 'dateOfInvoice': ('开票日期', ), | ||
1335 | } | ||
1341 | 1336 | ||
1342 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] | 1337 | UCI_COMPARE_LOGIC = { |
1338 | 'vinNo': ('车架号', ), | ||
1339 | 'vehicleTransactionAmount': ('价税合计小写', ), | ||
1340 | 'customerName': ('购方名称', ), | ||
1341 | 'idNum': ('购方纳税人识别号', ), | ||
1342 | } | ||
1343 | 1343 | ||
1344 | MVC_COMPARE_LOGIC = { | ||
1345 | 'vinNo': ('9.车辆识别代号/车架号', ), | ||
1346 | # 'customerName': ('姓名/名称', ), | ||
1347 | # 'idNum': ('身份证明名称/号码', ), | ||
1348 | # 'date': ('转移登记日期', ), | ||
1349 | } | ||
1344 | 1350 | ||
1345 | BC_COMPARE_LOGIC = [ | 1351 | BC_COMPARE_LOGIC = { |
1346 | ('accountNo', 'CardNum'), | 1352 | 'accountNo': ('CardNum', ), |
1347 | ('bankName', 'BankName'), | 1353 | 'bankName': ('BankName', ), |
1348 | ] | 1354 | } |
1349 | 1355 | ||
1350 | DDA_COMPARE_LOGIC = [ | 1356 | DDA_COMPARE_LOGIC = { |
1351 | ('applicationId(1)', 'CardNum'), | 1357 | 'applicationId(1)': ('check_Num', ), |
1352 | ('applicationId(2)', 'BankName'), | 1358 | 'applicationId(2)': ('check_Num', ), |
1353 | ('bankName', 'BankName'), | 1359 | 'bankName': ('to_bank', ), |
1354 | ('companyName', 'BankName'), | 1360 | 'companyName': ('to_company', ), |
1355 | ('customerName', 'BankName'), | 1361 | 'customerName': (DDA_IC_NAME, ), |
1356 | ('idNum', 'BankName'), | 1362 | 'idNum': (DDA_IC_ID, ), |
1357 | ('accountHolderName', 'BankName'), | 1363 | 'accountHolderName': (DDA_BC_NAME, ), |
1358 | ('accountNo', 'BankName'), | 1364 | 'accountNo': (DDA_BC_ID, ), |
1359 | ] | 1365 | } |
1360 | 1366 | ||
1361 | 1367 | ||
1362 | # MVC_OCR_FIELD = 'mvc_ocr' | 1368 | # MVC_OCR_FIELD = 'mvc_ocr' |
... | @@ -1369,6 +1375,7 @@ SE_COMPARE_FIELD = { | ... | @@ -1369,6 +1375,7 @@ SE_COMPARE_FIELD = { |
1369 | BL_EN: (BL_OCR_FIELD, BL_COMPARE_LOGIC, False), | 1375 | BL_EN: (BL_OCR_FIELD, BL_COMPARE_LOGIC, False), |
1370 | MVI_EN: (MVI_OCR_FIELD, MVI_COMPARE_LOGIC, False), | 1376 | MVI_EN: (MVI_OCR_FIELD, MVI_COMPARE_LOGIC, False), |
1371 | UCI_EN: (UCI_OCR_FIELD, UCI_COMPARE_LOGIC, False), | 1377 | UCI_EN: (UCI_OCR_FIELD, UCI_COMPARE_LOGIC, False), |
1378 | MVC_EN: (MVC_OCR_FIELD, MVC_COMPARE_LOGIC, False), | ||
1372 | BC_EN: (BC_OCR_FIELD, BC_COMPARE_LOGIC, False), | 1379 | BC_EN: (BC_OCR_FIELD, BC_COMPARE_LOGIC, False), |
1373 | DDA_EN: (DDA_OCR_FIELD, DDA_COMPARE_LOGIC, False), | 1380 | DDA_EN: (DDA_OCR_FIELD, DDA_COMPARE_LOGIC, False), |
1374 | } | 1381 | } | ... | ... |
... | @@ -507,23 +507,35 @@ def get_se_compare_info(last_obj, application_entity): | ... | @@ -507,23 +507,35 @@ def get_se_compare_info(last_obj, application_entity): |
507 | vehicle_info_dict = json.loads(last_obj.vehicle_info) # TODO 车辆登记证 | 507 | vehicle_info_dict = json.loads(last_obj.vehicle_info) # TODO 车辆登记证 |
508 | vehicle_info = {} | 508 | vehicle_info = {} |
509 | vehicle_field_input = [] | 509 | vehicle_field_input = [] |
510 | gb_field_input = [] | ||
510 | if vehicle_info_dict['vehicleStatus'] == 'New': | 511 | if vehicle_info_dict['vehicleStatus'] == 'New': |
511 | for vehicle_field in consts.SE_NEW_FIELD: | 512 | for vehicle_field in consts.SE_NEW_FIELD: |
512 | vehicle_field_input.append((vehicle_field, vehicle_info_dict[vehicle_field])) | 513 | vehicle_field_input.append((vehicle_field, vehicle_info_dict[vehicle_field])) |
513 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name)) | 514 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name)) |
514 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) | 515 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) |
515 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], last_obj.first_submmison_date)) | 516 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], last_obj.first_submmison_date)) |
517 | for gb_field in consts.SE_GB_NEW_FIELD: | ||
518 | gb_field_input.append((gb_field, vehicle_info_dict[gb_field])) | ||
516 | vehicle_info[consts.MVI_EN] = vehicle_field_input | 519 | vehicle_info[consts.MVI_EN] = vehicle_field_input |
520 | vehicle_info[consts.MVC_EN] = gb_field_input | ||
517 | else: | 521 | else: |
518 | for vehicle_field in consts.SE_USED_FIELD: | 522 | for vehicle_field in consts.SE_USED_FIELD: |
519 | vehicle_field_input.append((vehicle_field, vehicle_info_dict[vehicle_field])) | 523 | vehicle_field_input.append((vehicle_field, vehicle_info_dict[vehicle_field])) |
524 | for gb_field in consts.SE_GB_NEW_FIELD: | ||
525 | gb_field_input.append((gb_field, vehicle_info_dict[gb_field])) | ||
520 | if isinstance(company_info, tuple): | 526 | if isinstance(company_info, tuple): |
521 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], company_info[0])) | 527 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], company_info[0])) |
522 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], company_info[1])) | 528 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], company_info[1])) |
529 | # gb_field_input.append((consts.SE_GB_USED_FIELD[0], company_info[0])) | ||
530 | # gb_field_input.append((consts.SE_GB_USED_FIELD[1], company_info[1])) | ||
523 | else: | 531 | else: |
524 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name)) | 532 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], main_name)) |
525 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) | 533 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) |
534 | # gb_field_input.append((consts.SE_GB_USED_FIELD[0], main_name)) | ||
535 | # gb_field_input.append((consts.SE_GB_USED_FIELD[1], main_num)) | ||
536 | # gb_field_input.append((consts.SE_GB_USED_FIELD[2], last_obj.first_submmison_date)) | ||
526 | vehicle_info[consts.UCI_EN] = vehicle_field_input | 537 | vehicle_info[consts.UCI_EN] = vehicle_field_input |
538 | vehicle_info[consts.MVC_EN] = gb_field_input | ||
527 | compare_info['vehicleInfo'] = vehicle_info | 539 | compare_info['vehicleInfo'] = vehicle_info |
528 | 540 | ||
529 | bank_info_dict = json.loads(last_obj.bank_info) | 541 | bank_info_dict = json.loads(last_obj.bank_info) |
... | @@ -556,6 +568,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -556,6 +568,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
556 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | 568 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] |
557 | 569 | ||
558 | is_find = False | 570 | is_find = False |
571 | result_field_list = [] | ||
559 | ocr_res_str = ocr_res_dict.get(ocr_field) | 572 | ocr_res_str = ocr_res_dict.get(ocr_field) |
560 | if ocr_res_str is not None: | 573 | if ocr_res_str is not None: |
561 | ocr_res_list = json.loads(ocr_res_str) | 574 | ocr_res_list = json.loads(ocr_res_str) |
... | @@ -563,54 +576,46 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -563,54 +576,46 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
563 | 576 | ||
564 | # 身份证、居住证 过期期限特殊处理 | 577 | # 身份证、居住证 过期期限特殊处理 |
565 | if special_expiry_date: | 578 | if special_expiry_date: |
566 | expiry_dates = [] | 579 | expiry_dates = set() |
567 | key = compare_logic[2][1] | 580 | key = compare_logic.get('idExpiryDate')[0] |
568 | # for ocr_res in tmp_list: | ||
569 | for ocr_res in ocr_res_list: | 581 | for ocr_res in ocr_res_list: |
570 | if ocr_res.get(key): | 582 | if key in ocr_res: |
571 | expiry_dates.append(ocr_res.get(key)) | 583 | expiry_dates.add(ocr_res[key]) |
572 | else: | 584 | else: |
573 | expiry_dates = [] | 585 | expiry_dates = set() |
574 | 586 | ||
575 | # for ocr_res in tmp_list: | ||
576 | for ocr_res in ocr_res_list: | 587 | for ocr_res in ocr_res_list: |
577 | if is_find: | 588 | if is_find: |
578 | break | 589 | break |
579 | for idx, compare_tuple in enumerate(compare_list): | 590 | |
580 | input_str = info_dict.get(compare_tuple[0]) | 591 | for idx, (name, value) in enumerate(field_list): |
581 | ocr_str = ocr_res.get(compare_tuple[1]) | 592 | ocr_str = ocr_res.get(compare_logic[name][0]) |
582 | compare_res, ocr_output = getattr(cp, compare_tuple[2])( | 593 | if not isinstance(ocr_str, str): |
583 | input_str, ocr_str, idx, **compare_tuple[3]) | 594 | result = consts.RESULT_N |
584 | # 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)) | 595 | else: |
585 | if idx == 0 and compare_res in [consts.RESULT_N, consts.RESULT_NA] and length > 1: | 596 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
597 | |||
598 | if idx == 0 and result == consts.RESULT_N and length > 1: | ||
586 | break | 599 | break |
600 | |||
587 | is_find = True | 601 | is_find = True |
588 | 602 | ||
589 | # 过期期限特殊处理 | 603 | # 过期期限特殊处理 |
590 | if idx == 2 and has_expiry_date and compare_res == consts.RESULT_NA: | 604 | if special_expiry_date and name == 'idExpiryDate' and result == consts.RESULT_N: |
591 | for expiry_date in expiry_dates: | 605 | for expiry_date in expiry_dates: |
592 | expiry_date_compare_res, expiry_date_ocr_output = getattr(cp, compare_tuple[2])( | 606 | expiry_date_res = getattr(cp, compare_logic[name][1])(value, expiry_date, **compare_logic[name][2]) |
593 | input_str, expiry_date, idx, **compare_tuple[3] | 607 | if expiry_date_res == consts.RESULT_Y: |
594 | ) | ||
595 | if expiry_date_compare_res == consts.RESULT_Y: | ||
596 | compare_res = consts.RESULT_Y | ||
597 | ocr_output = expiry_date_ocr_output | ||
598 | ocr_str = expiry_date | 608 | ocr_str = expiry_date |
609 | result = expiry_date_res | ||
599 | break | 610 | break |
600 | 611 | ||
601 | info_dict[compare_tuple[4]] = compare_res | 612 | result_field_list.append((name, value, result, ocr_str)) |
602 | if input_str is not None: | 613 | |
603 | if ocr_str is None or ocr_output is None: | ||
604 | del info_dict[compare_tuple[0]] | ||
605 | else: | ||
606 | info_dict[compare_tuple[0]] = ocr_output | ||
607 | res_set.add(compare_res) | ||
608 | if not is_find: | 614 | if not is_find: |
609 | res_set.add(consts.RESULT_N) | 615 | for name, value in field_list: |
610 | for compare_tuple in compare_list: | 616 | result_field_list.append((name, value, consts.RESULT_N, '')) |
611 | info_dict[compare_tuple[4]] = consts.RESULT_NA | 617 | |
612 | if compare_tuple[0] in info_dict: | 618 | return result_field_list |
613 | del info_dict[compare_tuple[0]] | ||
614 | 619 | ||
615 | 620 | ||
616 | def se_compare_process(compare_info, ocr_res_dict): | 621 | def se_compare_process(compare_info, ocr_res_dict): | ... | ... |
-
Please register or sign in to post a comment