Merge branch 'feature/se' into feature/1223
Showing
6 changed files
with
432 additions
and
50 deletions
... | @@ -1178,6 +1178,9 @@ DDA_OCR_FIELD = 'bs_ocr' | ... | @@ -1178,6 +1178,9 @@ DDA_OCR_FIELD = 'bs_ocr' |
1178 | HMH_OCR_FIELD = 'hmh_ocr' | 1178 | HMH_OCR_FIELD = 'hmh_ocr' |
1179 | JYPZ_OCR_FIELD = 'jypz_ocr' | 1179 | JYPZ_OCR_FIELD = 'jypz_ocr' |
1180 | HT_FIELD = 'ht_ocr' | 1180 | HT_FIELD = 'ht_ocr' |
1181 | BD_FIELD = 'bd_ocr' | ||
1182 | BS_FIELD = 'bss_ocr' | ||
1183 | BS_CLASSIFY = 10087 | ||
1181 | 1184 | ||
1182 | RESULT_MAPPING = { | 1185 | RESULT_MAPPING = { |
1183 | MVI_CLASSIFY: MVI_OCR_FIELD, | 1186 | MVI_CLASSIFY: MVI_OCR_FIELD, |
... | @@ -1195,9 +1198,11 @@ RESULT_MAPPING = { | ... | @@ -1195,9 +1198,11 @@ RESULT_MAPPING = { |
1195 | HMH_CLASSIFY: HMH_OCR_FIELD, | 1198 | HMH_CLASSIFY: HMH_OCR_FIELD, |
1196 | JYPZ_CLASSIFY: JYPZ_OCR_FIELD, | 1199 | JYPZ_CLASSIFY: JYPZ_OCR_FIELD, |
1197 | CONTRACT_CLASSIFY: HT_FIELD, | 1200 | CONTRACT_CLASSIFY: HT_FIELD, |
1201 | INSURANCE_CLASSIFY: BD_FIELD, | ||
1202 | BS_CLASSIFY: BS_FIELD, | ||
1198 | } | 1203 | } |
1199 | 1204 | ||
1200 | CA_ADD_COMPARE_FIELDS = (IC_OCR_FIELD, BL_OCR_FIELD) | 1205 | CA_ADD_COMPARE_FIELDS = (IC_OCR_FIELD, BL_OCR_FIELD, BS_FIELD) |
1201 | 1206 | ||
1202 | COMPARE_FIELDS = (MVI_OCR_FIELD, | 1207 | COMPARE_FIELDS = (MVI_OCR_FIELD, |
1203 | IC_OCR_FIELD, | 1208 | IC_OCR_FIELD, |
... | @@ -1213,6 +1218,8 @@ COMPARE_FIELDS = (MVI_OCR_FIELD, | ... | @@ -1213,6 +1218,8 @@ COMPARE_FIELDS = (MVI_OCR_FIELD, |
1213 | HMH_OCR_FIELD, | 1218 | HMH_OCR_FIELD, |
1214 | JYPZ_OCR_FIELD, | 1219 | JYPZ_OCR_FIELD, |
1215 | HT_FIELD, | 1220 | HT_FIELD, |
1221 | BD_FIELD, | ||
1222 | BS_FIELD, | ||
1216 | ) | 1223 | ) |
1217 | 1224 | ||
1218 | # 身份证 | 1225 | # 身份证 |
... | @@ -1393,7 +1400,10 @@ SE_STAMP_VALUE = '有' | ... | @@ -1393,7 +1400,10 @@ SE_STAMP_VALUE = '有' |
1393 | SE_LAYOUT_VALUE = '旧版-旧打印、新版-新打印' | 1400 | SE_LAYOUT_VALUE = '旧版-旧打印、新版-新打印' |
1394 | SE_GB_NEW_FIELD = ['vinNo'] | 1401 | SE_GB_NEW_FIELD = ['vinNo'] |
1395 | SE_GB_USED_FIELD = ['customerName', 'idNum', 'date'] | 1402 | SE_GB_USED_FIELD = ['customerName', 'idNum', 'date'] |
1403 | SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人)户名', '(担保人)打印日期', '(担保人)流水日期'] | ||
1396 | SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] | 1404 | SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] |
1405 | SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计'] | ||
1406 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0'] | ||
1397 | 1407 | ||
1398 | SE_BANK_FIELD = ['accountNo', 'bankName'] | 1408 | SE_BANK_FIELD = ['accountNo', 'bankName'] |
1399 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] | 1409 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] |
... | @@ -1502,6 +1512,8 @@ DDA_EN = 'DDA' | ... | @@ -1502,6 +1512,8 @@ DDA_EN = 'DDA' |
1502 | HMH_EN = 'Mortgage Waiver Letter' | 1512 | HMH_EN = 'Mortgage Waiver Letter' |
1503 | JYPZ_EN = 'Used Car Document' | 1513 | JYPZ_EN = 'Used Car Document' |
1504 | AFC_CONTRACT_EN = 'AFC Contract' | 1514 | AFC_CONTRACT_EN = 'AFC Contract' |
1515 | BD_EN = 'Insurance' | ||
1516 | BS_EN = 'Bank Statement' | ||
1505 | 1517 | ||
1506 | SKIP_CARD = {SME_BL_EN} | 1518 | SKIP_CARD = {SME_BL_EN} |
1507 | 1519 | ||
... | @@ -1643,6 +1655,31 @@ HMH_COMPARE_LOGIC = { | ... | @@ -1643,6 +1655,31 @@ HMH_COMPARE_LOGIC = { |
1643 | '签字': ('借款人签字/盖章', 'se_common_compare', {}, '抵押登记豁免函签字需人工核查'), | 1655 | '签字': ('借款人签字/盖章', 'se_common_compare', {}, '抵押登记豁免函签字需人工核查'), |
1644 | } | 1656 | } |
1645 | 1657 | ||
1658 | BD_COMPARE_LOGIC = { | ||
1659 | '被保险人姓名': ('被保险人姓名', 'se_name_compare', {}, '保单被保险人姓名与系统不一致'), | ||
1660 | '被保险人证件号码': ('被保险人证件号码', 'se_common_compare', {}, '保单被保险人证件号码与系统不一致'), | ||
1661 | '车架号': ('车架号', 'se_common_compare', {}, '保单车架号与系统不一致'), | ||
1662 | '机动车损失保险金额': ('机动车损失保险金额', 'se_amount_lte_compare', {}, '保单车损险异常'), | ||
1663 | '第三者责任保险金额': ('机动车第三者责任保险金额', 'se_amount_lte_compare', {}, '保单三者险异常'), | ||
1664 | '绝对免赔率': ('机动车损失保险绝对免赔率/绝对免赔额', 'se_one_compare', {}, '保单无绝对免赔项'), | ||
1665 | '保险起始日期': ('保险起始日期', 'se_bd_date_compare', {'start': True}, '保单起始时间有误'), | ||
1666 | '保险截止日期': ('保险截止日期', 'se_bd_date_compare', {}, '保单截止时间有误'), | ||
1667 | '保单章': ('保单章', 'se_common_compare', {}, '保单无保单章'), | ||
1668 | '第一受益人': ('特别约定第一受益人', 'se_common_compare', {}, '保单第一受益人有误,需人工核查'), | ||
1669 | '保险费合计': ('保险费合计', 'se_amount_compare', {}, '保单保费疑似无法覆盖ASP保险融资'), | ||
1670 | } | ||
1671 | |||
1672 | BS_COMPARE_LOGIC = { | ||
1673 | '户名': ('role', 'se_one_compare', {}, '主共借人未提供银行流水'), | ||
1674 | '(担保人)户名': ('role', 'se_one_compare', {}, '担保人未提供银行流水,需人工查看直系亲属关系'), | ||
1675 | '打印日期': ('print_time', 'se_bs_print_date_compare', {}, '主共借人银行流水打印日期异常'), | ||
1676 | '(担保人)打印日期': ('print_time', 'se_bs_print_date_compare', {}, '担保人银行流水打印日期异常'), | ||
1677 | '流水日期': ('date', 'se_bs_date_compare', {}, '主共借人银行流水日期异常'), | ||
1678 | '(担保人)流水日期': ('date', 'se_bs_date_compare', {}, '担保人银行流水日期异常'), | ||
1679 | } | ||
1680 | |||
1681 | SPECIAL_REASON = '主共借人未提供银行流水,含担保人需人工查看直系亲属关系' | ||
1682 | |||
1646 | HT_COMPARE_LOGIC = { | 1683 | HT_COMPARE_LOGIC = { |
1647 | '合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), | 1684 | '合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), |
1648 | '所购车辆价格-小写-重要条款': ('所购车辆价格-小写-重要条款', 'se_amount_str_compare', {}, '合同首页中车辆价格与系统不一致'), | 1685 | '所购车辆价格-小写-重要条款': ('所购车辆价格-小写-重要条款', 'se_amount_str_compare', {}, '合同首页中车辆价格与系统不一致'), |
... | @@ -1710,7 +1747,9 @@ SE_COMPARE_FIELD = { | ... | @@ -1710,7 +1747,9 @@ SE_COMPARE_FIELD = { |
1710 | DDA_EN: (DDA_OCR_FIELD, DDA_COMPARE_LOGIC, False), | 1747 | DDA_EN: (DDA_OCR_FIELD, DDA_COMPARE_LOGIC, False), |
1711 | HMH_EN: (HMH_OCR_FIELD, HMH_COMPARE_LOGIC, False), | 1748 | HMH_EN: (HMH_OCR_FIELD, HMH_COMPARE_LOGIC, False), |
1712 | JYPZ_EN: (JYPZ_OCR_FIELD, JYPZ_COMPARE_LOGIC, False), | 1749 | JYPZ_EN: (JYPZ_OCR_FIELD, JYPZ_COMPARE_LOGIC, False), |
1713 | AFC_CONTRACT_EN: (HT_FIELD, HT_COMPARE_LOGIC, False) | 1750 | AFC_CONTRACT_EN: (HT_FIELD, HT_COMPARE_LOGIC, False), |
1751 | BD_EN: (BD_FIELD, BD_COMPARE_LOGIC, False), | ||
1752 | BS_EN: (BS_FIELD, BS_COMPARE_LOGIC, False), | ||
1714 | } | 1753 | } |
1715 | 1754 | ||
1716 | 1755 | ... | ... |
... | @@ -872,6 +872,43 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -872,6 +872,43 @@ class Command(BaseCommand, LoggerMixin): |
872 | summary['role'] = self.get_most(summary['role']) | 872 | summary['role'] = self.get_most(summary['role']) |
873 | return bs_summary | 873 | return bs_summary |
874 | 874 | ||
875 | def rebuild_bs(self, bs_summary): | ||
876 | # bs_summary = { | ||
877 | # '卡号': { | ||
878 | # 'classify': 0, | ||
879 | # 'confidence': 0.9, | ||
880 | # 'role': '柳雪', | ||
881 | # 'code': [('page', 'code'), ], | ||
882 | # 'verify': [(pno, ino, reason_str), ] | ||
883 | # 'print_time': 'datetime', | ||
884 | # 'start_date': 'datetime', | ||
885 | # 'end_date': 'datetime', | ||
886 | # 'sheet': ['sheet_name'] | ||
887 | # } | ||
888 | # } | ||
889 | res = [] | ||
890 | for bs_info in bs_summary.values(): | ||
891 | try: | ||
892 | print_date = bs_info.get('print_time', '').strftime("%Y-%m-%d") | ||
893 | except Exception as e: | ||
894 | print_date = '' | ||
895 | try: | ||
896 | start_date = bs_info.get('start_date', '').strftime("%Y-%m-%d") | ||
897 | except Exception as e: | ||
898 | start_date = '' | ||
899 | try: | ||
900 | end_date = bs_info.get('end_date', '').strftime("%Y-%m-%d") | ||
901 | except Exception as e: | ||
902 | end_date = '' | ||
903 | res.append( | ||
904 | { | ||
905 | 'role': bs_info.get('role', ''), | ||
906 | 'print_time': print_date, | ||
907 | 'date': [start_date, end_date], | ||
908 | } | ||
909 | ) | ||
910 | return res | ||
911 | |||
875 | def rebuild_contract(self, contract_result_compare): | 912 | def rebuild_contract(self, contract_result_compare): |
876 | res_list = [] | 913 | res_list = [] |
877 | for classify, page_info_dict in contract_result_compare.items(): | 914 | for classify, page_info_dict in contract_result_compare.items(): |
... | @@ -1626,6 +1663,10 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1626,6 +1663,10 @@ class Command(BaseCommand, LoggerMixin): |
1626 | if len(contract_result_compare_rebuild) > 0: | 1663 | if len(contract_result_compare_rebuild) > 0: |
1627 | license_summary[consts.CONTRACT_CLASSIFY] = contract_result_compare_rebuild | 1664 | license_summary[consts.CONTRACT_CLASSIFY] = contract_result_compare_rebuild |
1628 | 1665 | ||
1666 | bs_rebuild = self.rebuild_bs(merged_bs_summary) | ||
1667 | if len(bs_rebuild) > 0: | ||
1668 | license_summary[consts.BS_CLASSIFY] = bs_rebuild | ||
1669 | |||
1629 | # 比对 | 1670 | # 比对 |
1630 | if len(license_summary) > 0 and doc.document_scheme != consts.DOC_SCHEME_LIST[2]: | 1671 | if len(license_summary) > 0 and doc.document_scheme != consts.DOC_SCHEME_LIST[2]: |
1631 | try: | 1672 | try: | ... | ... |
... | @@ -314,6 +314,8 @@ class AFCOCRResult(models.Model): | ... | @@ -314,6 +314,8 @@ class AFCOCRResult(models.Model): |
314 | hmh_ocr = models.TextField(null=True, verbose_name="豁免函") | 314 | hmh_ocr = models.TextField(null=True, verbose_name="豁免函") |
315 | jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证") | 315 | jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证") |
316 | ht_ocr = models.TextField(null=True, verbose_name="AFC合同") | 316 | ht_ocr = models.TextField(null=True, verbose_name="AFC合同") |
317 | bd_ocr = models.TextField(null=True, verbose_name="保单") | ||
318 | bss_ocr = models.TextField(null=True, verbose_name="银行流水") | ||
317 | 319 | ||
318 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 320 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
319 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 321 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
... | @@ -344,6 +346,8 @@ class HILOCRResult(models.Model): | ... | @@ -344,6 +346,8 @@ class HILOCRResult(models.Model): |
344 | hmh_ocr = models.TextField(null=True, verbose_name="豁免函") | 346 | hmh_ocr = models.TextField(null=True, verbose_name="豁免函") |
345 | jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证") | 347 | jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证") |
346 | ht_ocr = models.TextField(null=True, verbose_name="AFC合同") | 348 | ht_ocr = models.TextField(null=True, verbose_name="AFC合同") |
349 | bd_ocr = models.TextField(null=True, verbose_name="保单") | ||
350 | bss_ocr = models.TextField(null=True, verbose_name="银行流水") | ||
347 | 351 | ||
348 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 352 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
349 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 353 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
... | @@ -373,6 +377,8 @@ class AFCSEOCRResult(models.Model): | ... | @@ -373,6 +377,8 @@ class AFCSEOCRResult(models.Model): |
373 | hmh_ocr = models.TextField(null=True, verbose_name="豁免函") | 377 | hmh_ocr = models.TextField(null=True, verbose_name="豁免函") |
374 | jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证") | 378 | jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证") |
375 | ht_ocr = models.TextField(null=True, verbose_name="AFC合同") | 379 | ht_ocr = models.TextField(null=True, verbose_name="AFC合同") |
380 | bd_ocr = models.TextField(null=True, verbose_name="保单") | ||
381 | bss_ocr = models.TextField(null=True, verbose_name="银行流水") | ||
376 | 382 | ||
377 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 383 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
378 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 384 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
... | @@ -403,6 +409,8 @@ class HILSEOCRResult(models.Model): | ... | @@ -403,6 +409,8 @@ class HILSEOCRResult(models.Model): |
403 | hmh_ocr = models.TextField(null=True, verbose_name="豁免函") | 409 | hmh_ocr = models.TextField(null=True, verbose_name="豁免函") |
404 | jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证") | 410 | jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证") |
405 | ht_ocr = models.TextField(null=True, verbose_name="AFC合同") | 411 | ht_ocr = models.TextField(null=True, verbose_name="AFC合同") |
412 | bd_ocr = models.TextField(null=True, verbose_name="保单") | ||
413 | bss_ocr = models.TextField(null=True, verbose_name="银行流水") | ||
406 | 414 | ||
407 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 415 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
408 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 416 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ... | ... |
... | @@ -879,8 +879,8 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -879,8 +879,8 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
879 | main_role_info = {} | 879 | main_role_info = {} |
880 | company_info_list = [] | 880 | company_info_list = [] |
881 | 881 | ||
882 | # 个人信息证件--------------------------------------------------------------------------------------------------------- | ||
882 | province = cms_info.get('province', '') | 883 | province = cms_info.get('province', '') |
883 | |||
884 | for individual_info in cms_info.get('applicantInformation', []): | 884 | for individual_info in cms_info.get('applicantInformation', []): |
885 | all_id_num = [] | 885 | all_id_num = [] |
886 | 886 | ||
... | @@ -908,6 +908,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -908,6 +908,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
908 | field_input.append(('idExpiryDate', id_info.get('idExpiryDate', ''))) | 908 | field_input.append(('idExpiryDate', id_info.get('idExpiryDate', ''))) |
909 | license_dict[license_en] = field_input | 909 | license_dict[license_en] = field_input |
910 | all_id_num.append(id_num) | 910 | all_id_num.append(id_num) |
911 | # 营业执照 -------------------------------------------------------------------------------------------------- | ||
911 | elif id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: | 912 | elif id_info.get('idType') in ['Unified Social Credit Code', 'Tax Number', 'Business License Number']: |
912 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', | 913 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', |
913 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] | 914 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] |
... | @@ -926,6 +927,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -926,6 +927,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
926 | if individual_info.get('customersubType', '') == 'Corporate': | 927 | if individual_info.get('customersubType', '') == 'Corporate': |
927 | company_info_list.append((customer_name, id_num)) | 928 | company_info_list.append((customer_name, id_num)) |
928 | 929 | ||
930 | # SME营业执照--------------------------------------------------------------------------------------------------- | ||
929 | if individual_info.get('customersubType', '').startswith('Self Employed'): | 931 | if individual_info.get('customersubType', '').startswith('Self Employed'): |
930 | sep_field_input = [ | 932 | sep_field_input = [ |
931 | ('legalRepName', customer_name), | 933 | ('legalRepName', customer_name), |
... | @@ -969,9 +971,10 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -969,9 +971,10 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
969 | vehicle_info = {} | 971 | vehicle_info = {} |
970 | vehicle_field_input = [] | 972 | vehicle_field_input = [] |
971 | vehicle_status = cms_info.get('vehicleStatus', '') | 973 | vehicle_status = cms_info.get('vehicleStatus', '') |
972 | first_submmison_date = cms_info.get('submissionDate', '') | 974 | first_submission_date = cms_info.get('submissionDate', '') |
973 | vin_no = cms_info.get('vehicleInformation', {}).get('vinNo', '') | 975 | vin_no = cms_info.get('vehicleInformation', {}).get('vinNo', '') |
974 | amount = str(cms_info.get('financialInformation', {}).get('vehiclePrice', '0.0')) | 976 | amount = str(cms_info.get('financialInformation', {}).get('vehiclePrice', '0.0')) |
977 | # 新车发票---------------------------------------------------------------------------------------------------------- | ||
975 | if vehicle_status == 'New': | 978 | if vehicle_status == 'New': |
976 | vehicle_field_input.append(('vinNo', vin_no)) | 979 | vehicle_field_input.append(('vinNo', vin_no)) |
977 | vehicle_field_input.append(('dealer', '、'.join([cms_info.get('dealerName', ''), cms_info.get('fapiaoIssuerDealer', '')]))) | 980 | vehicle_field_input.append(('dealer', '、'.join([cms_info.get('dealerName', ''), cms_info.get('fapiaoIssuerDealer', '')]))) |
... | @@ -983,7 +986,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -983,7 +986,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
983 | else: | 986 | else: |
984 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], hmh_name)) | 987 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[0], hmh_name)) |
985 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], hmh_id)) | 988 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[1], hmh_id)) |
986 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submmison_date)) | 989 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date)) |
987 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) | 990 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) |
988 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[4], consts.SE_FPL_VALUE)) | 991 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[4], consts.SE_FPL_VALUE)) |
989 | bhsj = float(amount) / 1.13 | 992 | bhsj = float(amount) / 1.13 |
... | @@ -994,6 +997,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -994,6 +997,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
994 | ]))) | 997 | ]))) |
995 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[6], consts.SE_LAYOUT_VALUE)) | 998 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[6], consts.SE_LAYOUT_VALUE)) |
996 | vehicle_info[consts.MVI_EN] = vehicle_field_input | 999 | vehicle_info[consts.MVI_EN] = vehicle_field_input |
1000 | # 二手车发票、交易凭证、绿本------------------------------------------------------------------------------------------ | ||
997 | else: | 1001 | else: |
998 | gb_field_input = [ | 1002 | gb_field_input = [ |
999 | ('vinNo', vin_no), | 1003 | ('vinNo', vin_no), |
... | @@ -1016,12 +1020,12 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1016,12 +1020,12 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1016 | jypz_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) | 1020 | jypz_field_input.append((consts.SE_NEW_ADD_FIELD[1], main_num)) |
1017 | gb34_field_input.append((consts.SE_GB_USED_FIELD[0], main_name)) | 1021 | gb34_field_input.append((consts.SE_GB_USED_FIELD[0], main_name)) |
1018 | gb34_field_input.append((consts.SE_GB_USED_FIELD[1], main_num)) | 1022 | gb34_field_input.append((consts.SE_GB_USED_FIELD[1], main_num)) |
1019 | gb34_field_input.append((consts.SE_GB_USED_FIELD[2], first_submmison_date)) | 1023 | gb34_field_input.append((consts.SE_GB_USED_FIELD[2], first_submission_date)) |
1020 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submmison_date)) | 1024 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[2], first_submission_date)) |
1021 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) | 1025 | vehicle_field_input.append((consts.SE_NEW_ADD_FIELD[3], consts.SE_STAMP_VALUE)) |
1022 | jypz_field_input.append(('vinNo', vin_no)) | 1026 | jypz_field_input.append(('vinNo', vin_no)) |
1023 | jypz_field_input.append(('vehicleTransactionAmount', amount)) | 1027 | jypz_field_input.append(('vehicleTransactionAmount', amount)) |
1024 | jypz_field_input.append((consts.SE_GB_USED_FIELD[-1], first_submmison_date)) | 1028 | jypz_field_input.append((consts.SE_GB_USED_FIELD[-1], first_submission_date)) |
1025 | 1029 | ||
1026 | vehicle_info[consts.MVC_EN] = gb_field_input | 1030 | vehicle_info[consts.MVC_EN] = gb_field_input |
1027 | vehicle_info[consts.MVC34_EN] = gb34_field_input | 1031 | vehicle_info[consts.MVC34_EN] = gb34_field_input |
... | @@ -1033,6 +1037,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1033,6 +1037,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1033 | vehicle_info[consts.UCI_EN] = vehicle_field_input | 1037 | vehicle_info[consts.UCI_EN] = vehicle_field_input |
1034 | compare_info['vehicleInfo'] = vehicle_info | 1038 | compare_info['vehicleInfo'] = vehicle_info |
1035 | 1039 | ||
1040 | # 银行卡------------------------------------------------------------------------------------------------------- | ||
1036 | bank_info = {} | 1041 | bank_info = {} |
1037 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') | 1042 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') |
1038 | account_no = decode_des(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key) | 1043 | account_no = decode_des(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key) |
... | @@ -1044,6 +1049,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1044,6 +1049,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1044 | ] | 1049 | ] |
1045 | bank_info[consts.BC_EN] = bank_field_input | 1050 | bank_info[consts.BC_EN] = bank_field_input |
1046 | 1051 | ||
1052 | # DDA------------------------------------------------------------------------------------------------------------ | ||
1047 | if is_gsyh or not detect_list[-1]: | 1053 | if is_gsyh or not detect_list[-1]: |
1048 | dda_field_input = [ | 1054 | dda_field_input = [ |
1049 | ('applicationId(1)', last_obj.application_id), | 1055 | ('applicationId(1)', last_obj.application_id), |
... | @@ -1058,9 +1064,38 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1058,9 +1064,38 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1058 | bank_info[consts.DDA_EN] = dda_field_input | 1064 | bank_info[consts.DDA_EN] = dda_field_input |
1059 | compare_info['bankInfo'] = bank_info | 1065 | compare_info['bankInfo'] = bank_info |
1060 | 1066 | ||
1067 | # 银行流水 -------------------------------------------------------------------- | ||
1068 | if cms_info.get('autoApprovedDetails', {}).get('aaType', '') in ['CAA1', 'CAA2']: | ||
1069 | bs_role_list = [] | ||
1070 | for applicant_type in consts.APPLICANT_TYPE_ORDER[:2]: | ||
1071 | if applicant_type in main_role_info: | ||
1072 | for bs_role, _, _ in main_role_info[applicant_type]: | ||
1073 | bs_role_list.append(bs_role) | ||
1074 | |||
1075 | bs_info = dict() | ||
1076 | bs_field_input = [ | ||
1077 | (consts.SE_BS_FIELD[0], bs_role_list), | ||
1078 | (consts.SE_BS_FIELD[1], first_submission_date), | ||
1079 | (consts.SE_BS_FIELD[2], '90天'), | ||
1080 | ] | ||
1081 | |||
1082 | dbr_bs_role_list = [] | ||
1083 | for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []): | ||
1084 | dbr_bs_role_list.append(dbr_bs_role) | ||
1085 | if len(dbr_bs_role_list) > 0: | ||
1086 | bs_field_input.extend([ | ||
1087 | (consts.SE_BS_FIELD[3], dbr_bs_role_list), | ||
1088 | (consts.SE_BS_FIELD[4], first_submission_date), | ||
1089 | (consts.SE_BS_FIELD[5], '90天'), | ||
1090 | ]) | ||
1091 | bs_info[consts.BS_EN] = bs_field_input | ||
1092 | compare_info['Bank Statement'] = bs_info | ||
1093 | |||
1094 | |||
1095 | # 抵押登记豁免函---------------------------------------------------------------------------------------------------- | ||
1096 | other_info = {} | ||
1061 | full_no = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') | 1097 | full_no = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') |
1062 | if cms_info.get('mortgageType', '') == 'Mortgage Free' or cms_info.get('mortgageType', '') == 'MortgageFree': | 1098 | if cms_info.get('mortgageType', '') == 'Mortgage Free' or cms_info.get('mortgageType', '') == 'MortgageFree': |
1063 | other_info = {} | ||
1064 | hmh_field_input = [ | 1099 | hmh_field_input = [ |
1065 | (consts.SE_HMH_FIELD[0], hmh_name), | 1100 | (consts.SE_HMH_FIELD[0], hmh_name), |
1066 | (consts.SE_HMH_FIELD[1], hmh_id), | 1101 | (consts.SE_HMH_FIELD[1], hmh_id), |
... | @@ -1069,11 +1104,96 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1069,11 +1104,96 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1069 | (consts.SE_HMH_FIELD[4], consts.SE_STAMP_VALUE), | 1104 | (consts.SE_HMH_FIELD[4], consts.SE_STAMP_VALUE), |
1070 | ] | 1105 | ] |
1071 | other_info[consts.HMH_EN] = hmh_field_input | 1106 | other_info[consts.HMH_EN] = hmh_field_input |
1107 | |||
1108 | # ASP ------------------------------------------------------------------------------------------------------- | ||
1109 | asp_list = [] | ||
1110 | gzs_status = consts.GZS_STATUS[1] | ||
1111 | gzs_list = [gzs_status] | ||
1112 | gzs_price = '0.00' | ||
1113 | is_asp = False | ||
1114 | insurance_price = None | ||
1115 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) != '0.00': | ||
1116 | is_asp = True | ||
1117 | # for asp_info in cms_info.get('associatedServices', []): | ||
1118 | for asp_info in cms_info.get('associatedServices', {}).get('SubassociatedServices', []): | ||
1119 | tmp_asp_name = asp_info.get('associatedServices') | ||
1120 | if isinstance(tmp_asp_name, str) and len(tmp_asp_name) > 0: | ||
1121 | if gzs_status == consts.GZS_STATUS[1] and tmp_asp_name.find(consts.GZS_NAME) != -1: | ||
1122 | gzs_status = consts.GZS_STATUS[2] | ||
1123 | gzs_price = asp_info.get('price', '0.00') | ||
1124 | asp_list.append( | ||
1125 | ( | ||
1126 | tmp_asp_name, | ||
1127 | asp_info.get('price', '0.00'), | ||
1128 | asp_info.get('financed', '0.00') | ||
1129 | ) | ||
1130 | ) | ||
1131 | # 保单费合计 | ||
1132 | if tmp_asp_name.find('机动车辆保险') != -1: | ||
1133 | insurance_price = asp_info.get('price', '0.00') | ||
1134 | |||
1135 | # fin_total = 0 | ||
1136 | fin_total_tmp = cms_info.get('associatedServices', {}).get('financed total', '0.00') | ||
1137 | fin_total = '0.00' if fin_total_tmp.strip() == '' else fin_total_tmp | ||
1138 | for asp_name, _, asp_fin in asp_list: | ||
1139 | if gzs_status == consts.GZS_STATUS[2] and asp_name.find(consts.GZS_NAME) == -1: | ||
1140 | gzs_status = consts.GZS_STATUS[0] | ||
1141 | # fin_total += float(asp_fin) | ||
1142 | asp_list.append( | ||
1143 | ( | ||
1144 | consts.ASP_SUM_NAME, | ||
1145 | '', | ||
1146 | fin_total, | ||
1147 | # format(fin_total, '.2f'), | ||
1148 | ) | ||
1149 | ) | ||
1150 | |||
1151 | # CMS Vehicle Price / 1.13 * 10 % | ||
1152 | if gzs_status != consts.GZS_STATUS[1]: | ||
1153 | gzs_value = float(amount) * 0.1 / 1.13 | ||
1154 | gzs_list.append(gzs_value) | ||
1155 | gzs_list.append(float(gzs_price)) | ||
1156 | |||
1157 | # 保单 ----------------------------------------------------------------------------------------------------------- | ||
1158 | is_insurance = 0 | ||
1159 | insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') | ||
1160 | if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str): | ||
1161 | is_insurance = 1 | ||
1162 | elif insurance_type == 'Comprehensive Insurance': | ||
1163 | is_insurance = 2 | ||
1164 | if is_insurance != 0: | ||
1165 | fp_campaign = cms_info.get('fpCampaign', '') | ||
1166 | if fp_campaign.find('OCU') == -1: | ||
1167 | ssx_amount = amount | ||
1168 | else: | ||
1169 | ssx_amount = format(float(amount) * 0.8, '.2f') | ||
1170 | if fp_campaign.find('Joy_Plus') == -1: | ||
1171 | dszx_amount = '200000' | ||
1172 | else: | ||
1173 | dszx_amount = '500000' | ||
1174 | bd_field_input = [ | ||
1175 | (consts.SE_BD_FIELD[0], hmh_name), | ||
1176 | (consts.SE_BD_FIELD[1], hmh_id), | ||
1177 | (consts.SE_BD_FIELD[2], vin_no), | ||
1178 | (consts.SE_BD_FIELD[3], ssx_amount), | ||
1179 | (consts.SE_BD_FIELD[4], dszx_amount), | ||
1180 | (consts.SE_BD_FIELD[5], consts.JDMPV_VALUE), | ||
1181 | (consts.SE_BD_FIELD[6], cms_info.get('insuranceDetails', {}).get('startDate', '')), | ||
1182 | (consts.SE_BD_FIELD[7], cms_info.get('insuranceDetails', {}).get('endDate', '')), | ||
1183 | (consts.SE_BD_FIELD[8], consts.SE_STAMP_VALUE), | ||
1184 | (consts.SE_BD_FIELD[9], consts.SE_STAMP_VALUE), | ||
1185 | ] | ||
1186 | if is_insurance == 1: | ||
1187 | bd_field_input.append((consts.SE_BD_FIELD[10], insurance_price)) | ||
1188 | other_info[consts.BD_EN] = bd_field_input | ||
1189 | |||
1190 | if len(other_info) > 0: | ||
1072 | compare_info['other'] = other_info | 1191 | compare_info['other'] = other_info |
1073 | 1192 | ||
1074 | if application_entity in consts.HIL_SET: | 1193 | if application_entity in consts.HIL_SET: |
1075 | return compare_info, cms_info.get('applicationVersion', 1) | 1194 | return compare_info, cms_info.get('applicationVersion', 1) |
1076 | 1195 | ||
1196 | # AFC合同----------------------------------------------------------------------------------------------------------- | ||
1077 | contract_info = {} | 1197 | contract_info = {} |
1078 | 1198 | ||
1079 | schedule_list = [] | 1199 | schedule_list = [] |
... | @@ -1105,51 +1225,15 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1105,51 +1225,15 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1105 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), | 1225 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), |
1106 | ] | 1226 | ] |
1107 | 1227 | ||
1108 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) == '0.00': | 1228 | if is_asp: |
1229 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[20], asp_list)) | ||
1230 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], asp_list)) | ||
1231 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], gzs_list)) | ||
1232 | else: | ||
1109 | afc_contract_input.pop(5) | 1233 | afc_contract_input.pop(5) |
1110 | afc_contract_input.pop(5) | 1234 | afc_contract_input.pop(5) |
1111 | afc_contract_input.pop(9) | 1235 | afc_contract_input.pop(9) |
1112 | afc_contract_input.pop(9) | 1236 | afc_contract_input.pop(9) |
1113 | else: | ||
1114 | asp_list = [] | ||
1115 | gzs_status = consts.GZS_STATUS[1] | ||
1116 | gzs_price = '0.00' | ||
1117 | for asp_info in cms_info.get('associatedServices', {}).get('SubassociatedServices', []): | ||
1118 | tmp_asp_name = asp_info.get('associatedServices') | ||
1119 | if isinstance(tmp_asp_name, str) and len(tmp_asp_name) > 0: | ||
1120 | if gzs_status == consts.GZS_STATUS[1] and tmp_asp_name.find(consts.GZS_NAME) != -1: | ||
1121 | gzs_status = consts.GZS_STATUS[2] | ||
1122 | gzs_price = asp_info.get('price', '0.00') | ||
1123 | asp_list.append( | ||
1124 | ( | ||
1125 | tmp_asp_name, | ||
1126 | asp_info.get('price', '0.00'), | ||
1127 | asp_info.get('financed', '0.00') | ||
1128 | ) | ||
1129 | ) | ||
1130 | |||
1131 | fin_total_tmp = cms_info.get('associatedServices', {}).get('financed total', '0.00') | ||
1132 | fin_total = '0.00' if fin_total_tmp.strip() == '' else fin_total_tmp | ||
1133 | for asp_name, _, asp_fin in asp_list: | ||
1134 | if gzs_status == consts.GZS_STATUS[2] and asp_name.find(consts.GZS_NAME) == -1: | ||
1135 | gzs_status = consts.GZS_STATUS[0] | ||
1136 | asp_list.append( | ||
1137 | ( | ||
1138 | consts.ASP_SUM_NAME, | ||
1139 | '', | ||
1140 | fin_total, | ||
1141 | ) | ||
1142 | ) | ||
1143 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[20], asp_list)) | ||
1144 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], asp_list)) | ||
1145 | |||
1146 | # CMS Vehicle Price / 1.13 * 10 % | ||
1147 | gzs_list = [gzs_status] | ||
1148 | if gzs_status != consts.GZS_STATUS[1]: | ||
1149 | gzs_value = float(amount) * 0.1 / 1.13 | ||
1150 | gzs_list.append(gzs_value) | ||
1151 | gzs_list.append(float(gzs_price)) | ||
1152 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], gzs_list)) | ||
1153 | 1237 | ||
1154 | # '借款人签字及时间', 'Borrower', 0, 0, True | 1238 | # '借款人签字及时间', 'Borrower', 0, 0, True |
1155 | online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign' | 1239 | online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign' |
... | @@ -1352,6 +1436,124 @@ def get_se_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1352,6 +1436,124 @@ def get_se_compare_info(last_obj, application_entity, detect_list): |
1352 | return compare_info | 1436 | return compare_info |
1353 | 1437 | ||
1354 | 1438 | ||
1439 | def se_bs_compare(license_en, ocr_res_dict, strip_list): | ||
1440 | # 主共借至少提供一个 | ||
1441 | # 有担保人,担保人必须提供。主共借没有时,修改comment:人工查看担保人亲属关系 | ||
1442 | |||
1443 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] | ||
1444 | ocr_res_str = ocr_res_dict.get(ocr_field) | ||
1445 | |||
1446 | result_field_list = [] | ||
1447 | field_img_path_dict = dict() | ||
1448 | |||
1449 | if ocr_res_str is not None: | ||
1450 | pre_field_list = strip_list[:3] | ||
1451 | suf_field_list = strip_list[3:] | ||
1452 | |||
1453 | ocr_res_list = json.loads(ocr_res_str) | ||
1454 | # length = len(ocr_res_list) | ||
1455 | |||
1456 | # 主共借人 | ||
1457 | pre_best_res = {} | ||
1458 | max_correct_count = 0 | ||
1459 | for ocr_res in ocr_res_list: | ||
1460 | correct_count = 0 | ||
1461 | pre_tmp_res_part = {} | ||
1462 | for idx, (name, value) in enumerate(pre_field_list): | ||
1463 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | ||
1464 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | ||
1465 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | ||
1466 | if isinstance(ocr_str_or_list, list): | ||
1467 | ocr_str = json.dumps(ocr_str_or_list, ensure_ascii=False) | ||
1468 | else: | ||
1469 | ocr_str = ocr_str_or_list | ||
1470 | reason = compare_logic[name][3] | ||
1471 | else: | ||
1472 | result = consts.RESULT_N | ||
1473 | ocr_str = empty_str | ||
1474 | reason = compare_logic[name][3] | ||
1475 | |||
1476 | if idx == 0 and result == consts.RESULT_N: | ||
1477 | break | ||
1478 | |||
1479 | if result == consts.RESULT_Y: | ||
1480 | correct_count += 1 | ||
1481 | pre_tmp_res_part[name] = (result, ocr_str, reason) | ||
1482 | |||
1483 | if correct_count > 0 and correct_count >= max_correct_count: | ||
1484 | max_correct_count = correct_count | ||
1485 | pre_best_res = pre_tmp_res_part | ||
1486 | |||
1487 | for name, value in pre_field_list: | ||
1488 | if len(pre_best_res) > 0: | ||
1489 | result, ocr_str, reason = pre_best_res[name] | ||
1490 | else: | ||
1491 | result = consts.RESULT_N | ||
1492 | ocr_str = empty_str | ||
1493 | if len(suf_field_list) > 0: | ||
1494 | reason = consts.SPECIAL_REASON | ||
1495 | else: | ||
1496 | reason = compare_logic[pre_field_list[0][0]][3] | ||
1497 | img_path = empty_str | ||
1498 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
1499 | if isinstance(value, list): | ||
1500 | value = json.dumps(value, ensure_ascii=False) | ||
1501 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, reason)) | ||
1502 | |||
1503 | # 担保人 | ||
1504 | if len(suf_field_list) > 0: | ||
1505 | suf_best_res = {} | ||
1506 | max_correct_count = 0 | ||
1507 | for ocr_res in ocr_res_list: | ||
1508 | correct_count = 0 | ||
1509 | suf_tmp_res_part = {} | ||
1510 | for idx, (name, value) in enumerate(suf_field_list): | ||
1511 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | ||
1512 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | ||
1513 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | ||
1514 | if isinstance(ocr_str_or_list, list): | ||
1515 | ocr_str = json.dumps(ocr_str_or_list, ensure_ascii=False) | ||
1516 | else: | ||
1517 | ocr_str = ocr_str_or_list | ||
1518 | reason = compare_logic[name][3] | ||
1519 | else: | ||
1520 | result = consts.RESULT_N | ||
1521 | ocr_str = empty_str | ||
1522 | reason = compare_logic[name][3] | ||
1523 | |||
1524 | if idx == 0 and result == consts.RESULT_N: | ||
1525 | break | ||
1526 | |||
1527 | if result == consts.RESULT_Y: | ||
1528 | correct_count += 1 | ||
1529 | suf_tmp_res_part[name] = (result, ocr_str, reason) | ||
1530 | |||
1531 | if correct_count > 0 and correct_count >= max_correct_count: | ||
1532 | max_correct_count = correct_count | ||
1533 | suf_best_res = suf_tmp_res_part | ||
1534 | |||
1535 | for name, value in suf_field_list: | ||
1536 | if len(suf_best_res) > 0: | ||
1537 | result, ocr_str, reason = suf_best_res[name] | ||
1538 | else: | ||
1539 | result = consts.RESULT_N | ||
1540 | ocr_str = empty_str | ||
1541 | reason = compare_logic[suf_field_list[0][0]][3] | ||
1542 | img_path = empty_str | ||
1543 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
1544 | if isinstance(value, list): | ||
1545 | value = json.dumps(value, ensure_ascii=False) | ||
1546 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, reason)) | ||
1547 | else: | ||
1548 | for name, value in strip_list: | ||
1549 | if isinstance(value, list): | ||
1550 | value = json.dumps(value, ensure_ascii=False) | ||
1551 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, | ||
1552 | '未提供银行流水')) | ||
1553 | |||
1554 | return result_field_list, field_img_path_dict | ||
1555 | |||
1556 | |||
1355 | def se_compare_license(license_en, ocr_res_dict, field_list): | 1557 | def se_compare_license(license_en, ocr_res_dict, field_list): |
1356 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | 1558 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] |
1357 | 1559 | ||
... | @@ -1441,6 +1643,8 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -1441,6 +1643,8 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
1441 | special_expiry_date_slice = True | 1643 | special_expiry_date_slice = True |
1442 | else: | 1644 | else: |
1443 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str | 1645 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str |
1646 | if isinstance(value, list): | ||
1647 | value = json.dumps(value, ensure_ascii=False) | ||
1444 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | 1648 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value |
1445 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) | 1649 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) |
1446 | else: | 1650 | else: |
... | @@ -1448,6 +1652,8 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -1448,6 +1652,8 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
1448 | 1652 | ||
1449 | if not is_find: | 1653 | if not is_find: |
1450 | for name, value in field_list: | 1654 | for name, value in field_list: |
1655 | if isinstance(value, list): | ||
1656 | value = json.dumps(value, ensure_ascii=False) | ||
1451 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, '{0}未找到'.format(license_en))) | 1657 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, '{0}未找到'.format(license_en))) |
1452 | 1658 | ||
1453 | if is_find: | 1659 | if is_find: |
... | @@ -1756,6 +1962,8 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1756,6 +1962,8 @@ def se_compare_process(compare_info, ocr_res_dict): |
1756 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list) | 1962 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list) |
1757 | elif license_en == consts.AFC_CONTRACT_EN: | 1963 | elif license_en == consts.AFC_CONTRACT_EN: |
1758 | result_field_list, field_img_path_dict = se_afc_contract_compare(license_en, ocr_res_dict, strip_list) | 1964 | result_field_list, field_img_path_dict = se_afc_contract_compare(license_en, ocr_res_dict, strip_list) |
1965 | elif license_en == consts.BS_EN: | ||
1966 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list) | ||
1759 | else: | 1967 | else: |
1760 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) | 1968 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) |
1761 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | 1969 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | ... | ... |
... | @@ -363,6 +363,15 @@ class Comparison: | ... | @@ -363,6 +363,15 @@ class Comparison: |
363 | input_tmp = input_str.replace('元', '').replace(',', '') | 363 | input_tmp = input_str.replace('元', '').replace(',', '') |
364 | return self.build_res(ocr_tmp == input_tmp) | 364 | return self.build_res(ocr_tmp == input_tmp) |
365 | 365 | ||
366 | def se_amount_lte_compare(self, input_str, ocr_str, **kwargs): | ||
367 | try: | ||
368 | float_input = float(input_str) | ||
369 | float_ocr = float(ocr_str) | ||
370 | except Exception as e: | ||
371 | return self.RESULT_N | ||
372 | else: | ||
373 | return self.build_res(float_ocr >= float_input) | ||
374 | |||
366 | def se_amount_compare(self, input_str, ocr_str, **kwargs): | 375 | def se_amount_compare(self, input_str, ocr_str, **kwargs): |
367 | if input_str == ocr_str: | 376 | if input_str == ocr_str: |
368 | return self.RESULT_Y | 377 | return self.RESULT_Y |
... | @@ -375,6 +384,12 @@ class Comparison: | ... | @@ -375,6 +384,12 @@ class Comparison: |
375 | else: | 384 | else: |
376 | return self.build_res(float_ocr == float_input) | 385 | return self.build_res(float_ocr == float_input) |
377 | 386 | ||
387 | def se_one_compare(self, input_list, ocr_str, **kwargs): | ||
388 | if isinstance(input_list, list): | ||
389 | if ocr_str in input_list: | ||
390 | return self.RESULT_Y | ||
391 | return self.RESULT_N | ||
392 | |||
378 | def se_company_compare(self, input_str, ocr_str, **kwargs): | 393 | def se_company_compare(self, input_str, ocr_str, **kwargs): |
379 | input_tmp = re.sub(self.re_obj, '', input_str).strip() | 394 | input_tmp = re.sub(self.re_obj, '', input_str).strip() |
380 | ocr_tmp = re.sub(self.re_obj, '', ocr_str).strip() | 395 | ocr_tmp = re.sub(self.re_obj, '', ocr_str).strip() |
... | @@ -439,6 +454,46 @@ class Comparison: | ... | @@ -439,6 +454,46 @@ class Comparison: |
439 | else: | 454 | else: |
440 | return self.build_res(compare_date <= ocr_date) | 455 | return self.build_res(compare_date <= ocr_date) |
441 | 456 | ||
457 | def se_bd_date_compare(self, input_str, ocr_str, **kwargs): | ||
458 | try: | ||
459 | input_date = datetime.strptime(input_str, "%Y-%m-%d").date() | ||
460 | ocr_date = datetime.strptime(ocr_str, "%Y-%m-%d").date() | ||
461 | if kwargs.get('start', False): | ||
462 | if input_date != ocr_date: | ||
463 | return self.RESULT_N | ||
464 | |||
465 | six_month_date = (datetime.today() - relativedelta(months=6)).date() | ||
466 | today_date = datetime.today().date() | ||
467 | return self.build_res(six_month_date <= ocr_date <= today_date) | ||
468 | else: | ||
469 | if input_date == ocr_date or ocr_date == input_date + relativedelta(days=1): | ||
470 | return self.RESULT_Y | ||
471 | return self.RESULT_N | ||
472 | except Exception as e: | ||
473 | return self.RESULT_N | ||
474 | |||
475 | def se_bs_print_date_compare(self, input_str, ocr_str, **kwargs): | ||
476 | try: | ||
477 | input_date = datetime.strptime(input_str, "%Y-%m-%d") | ||
478 | ocr_date = datetime.strptime(ocr_str, "%Y-%m-%d") | ||
479 | if ocr_date >= input_date - relativedelta(days=15): | ||
480 | return self.RESULT_Y | ||
481 | return self.RESULT_N | ||
482 | except Exception as e: | ||
483 | return self.RESULT_N | ||
484 | |||
485 | def se_bs_date_compare(self, input_str, ocr_str_list, **kwargs): | ||
486 | if isinstance(ocr_str_list, list) and len(ocr_str_list) == 2: | ||
487 | try: | ||
488 | start_date = datetime.strptime(ocr_str_list[0], "%Y-%m-%d") | ||
489 | end_date = datetime.strptime(ocr_str_list[1], "%Y-%m-%d") | ||
490 | if end_date >= start_date + relativedelta(months=3): | ||
491 | return self.RESULT_Y | ||
492 | return self.RESULT_N | ||
493 | except Exception as e: | ||
494 | return self.RESULT_N | ||
495 | return self.RESULT_N | ||
496 | |||
442 | 497 | ||
443 | cp = Comparison() | 498 | cp = Comparison() |
444 | 499 | ... | ... |
src/common/tools/mssql_script11.py
0 → 100644
1 | import pyodbc | ||
2 | |||
3 | hil_sql = """ | ||
4 | ALTER TABLE hil_ocr_result ADD bd_ocr nvarchar(max); | ||
5 | ALTER TABLE hil_ocr_result ADD bss_ocr nvarchar(max); | ||
6 | ALTER TABLE hil_se_ocr_result ADD bd_ocr nvarchar(max); | ||
7 | ALTER TABLE hil_se_ocr_result ADD bss_ocr nvarchar(max); | ||
8 | """ | ||
9 | |||
10 | afc_sql = """ | ||
11 | ALTER TABLE afc_ocr_result ADD bd_ocr nvarchar(max); | ||
12 | ALTER TABLE afc_ocr_result ADD bss_ocr nvarchar(max); | ||
13 | ALTER TABLE afc_se_ocr_result ADD bss_ocr nvarchar(max); | ||
14 | ALTER TABLE afc_se_ocr_result ADD bd_ocr nvarchar(max); | ||
15 | """ | ||
16 | |||
17 | hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
18 | |||
19 | hil_cursor = hil_cnxn.cursor() | ||
20 | hil_cursor.execute(hil_sql) | ||
21 | |||
22 | hil_cursor.close() | ||
23 | hil_cnxn.close() | ||
24 | |||
25 | afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True) | ||
26 | |||
27 | afc_cursor = afc_cnxn.cursor() | ||
28 | afc_cursor.execute(afc_sql) | ||
29 | |||
30 | afc_cursor.close() | ||
31 | afc_cnxn.close() |
-
Please register or sign in to post a comment