Merge branch 'feature/CHINARPA-4660'
Showing
5 changed files
with
368 additions
and
18 deletions
| ... | @@ -1248,6 +1248,8 @@ FSM_CONTRACT_WEP_FIELD = 'fsm_wep_ocr' | ... | @@ -1248,6 +1248,8 @@ FSM_CONTRACT_WEP_FIELD = 'fsm_wep_ocr' |
| 1248 | FSM_CONTRACT_MSI_FIELD = 'fsm_msi_ocr' | 1248 | FSM_CONTRACT_MSI_FIELD = 'fsm_msi_ocr' |
| 1249 | FSM_CONTRACT_SC_FIELD = 'fsm_sc_ocr' | 1249 | FSM_CONTRACT_SC_FIELD = 'fsm_sc_ocr' |
| 1250 | FSM_CONTRACT_SC2_FIELD = 'fsm_sc2_ocr' | 1250 | FSM_CONTRACT_SC2_FIELD = 'fsm_sc2_ocr' |
| 1251 | FS_FIELD = 'fs_ocr' | ||
| 1252 | FSS_FIELD = 'fss_ocr' | ||
| 1251 | 1253 | ||
| 1252 | 1254 | ||
| 1253 | BS_CLASSIFY = 10089 | 1255 | BS_CLASSIFY = 10089 |
| ... | @@ -1304,6 +1306,8 @@ COMPARE_FIELDS = ( | ... | @@ -1304,6 +1306,8 @@ COMPARE_FIELDS = ( |
| 1304 | HIL_CONTRACT_1_FIELD, | 1306 | HIL_CONTRACT_1_FIELD, |
| 1305 | HIL_CONTRACT_2_FIELD, | 1307 | HIL_CONTRACT_2_FIELD, |
| 1306 | HIL_CONTRACT_3_FIELD, | 1308 | HIL_CONTRACT_3_FIELD, |
| 1309 | FS_FIELD, | ||
| 1310 | FSS_FIELD, | ||
| 1307 | ) | 1311 | ) |
| 1308 | 1312 | ||
| 1309 | PRE_COMPARE_FIELDS = ( | 1313 | PRE_COMPARE_FIELDS = ( |
| ... | @@ -1505,6 +1509,8 @@ SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', ' | ... | @@ -1505,6 +1509,8 @@ SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', ' |
| 1505 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', ''] | 1509 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', ''] |
| 1506 | JYPZ_TYPE_1 = ['二手车交易凭证'] | 1510 | JYPZ_TYPE_1 = ['二手车交易凭证'] |
| 1507 | JYPZ_TYPE_2 = ['BMW官方认证二手车交易凭证', '二手车交易凭证'] | 1511 | JYPZ_TYPE_2 = ['BMW官方认证二手车交易凭证', '二手车交易凭证'] |
| 1512 | SE_FS_FIELD = ['Hash值', '公章', '财年', '资产负债表内容', '利润表内容'] | ||
| 1513 | SE_FSS_FIELD = ['公司名称', '公章'] | ||
| 1508 | 1514 | ||
| 1509 | SE_BANK_FIELD = ['accountNo', 'bankName'] | 1515 | SE_BANK_FIELD = ['accountNo', 'bankName'] |
| 1510 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] | 1516 | SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo'] |
| ... | @@ -1818,8 +1824,11 @@ BS_EN = 'Bank Statement' | ... | @@ -1818,8 +1824,11 @@ BS_EN = 'Bank Statement' |
| 1818 | HIL_CONTRACT_1_EN = '售后回租合同' | 1824 | HIL_CONTRACT_1_EN = '售后回租合同' |
| 1819 | HIL_CONTRACT_2_EN = '车辆租赁抵押合同' | 1825 | HIL_CONTRACT_2_EN = '车辆租赁抵押合同' |
| 1820 | HIL_CONTRACT_3_EN = '车辆处置协议' | 1826 | HIL_CONTRACT_3_EN = '车辆处置协议' |
| 1827 | FS_EN = 'Financial Statement' | ||
| 1828 | FSS_EN = 'Financial Statement Supplementary' | ||
| 1821 | 1829 | ||
| 1822 | DDA_NO_FIND = '需人工查看DDA或截图' | 1830 | DDA_NO_FIND = '需人工查看DDA或截图' |
| 1831 | FS_NO_FIND = '未提供财报或财报不完整' | ||
| 1823 | 1832 | ||
| 1824 | SKIP_CARD = {SME_BL_EN} | 1833 | SKIP_CARD = {SME_BL_EN} |
| 1825 | 1834 | ||
| ... | @@ -2160,6 +2169,20 @@ HT_COMPARE_LOGIC = { | ... | @@ -2160,6 +2169,20 @@ HT_COMPARE_LOGIC = { |
| 2160 | '无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1), | 2169 | '无ASP产品': ('无ASP产品', 'se_self_compare_other_asp', {}, GZS_REASON_1), |
| 2161 | } | 2170 | } |
| 2162 | 2171 | ||
| 2172 | # 格式:'xueao给的excel字段名':('数据库字段名','比对逻辑','特殊处理可以忽略','比对不合格时的返回内容') | ||
| 2173 | FS_COMPARE_LOGIC = { | ||
| 2174 | 'Hash值': ('code', 'hash_code_compare', {}, '财报Hash值与系统不一致'), | ||
| 2175 | '公章': ('stamp', 'stamp_dict_compare', {}, '财报无公章'), | ||
| 2176 | '财年': ('财年', 'fiscal_year_compare', {}, '财报所属财年错误'), | ||
| 2177 | '资产负债表内容': ('资产负债表内容', 'input_list_not_zero_compare', {}, '财报资产负债表为空'), | ||
| 2178 | '利润表内容': ('利润表内容', 'input_list_not_zero_compare', {}, '财报利润表为空'), | ||
| 2179 | } | ||
| 2180 | |||
| 2181 | FSS_COMPARE_LOGIC = { | ||
| 2182 | '公司名称': ('title', 'se_company_compare', {}, '财报情况说明公司名称错误'), | ||
| 2183 | '公章': ('stamp', 'stamp_str_compare', {}, '财报情况说明无公章'), | ||
| 2184 | } | ||
| 2185 | |||
| 2163 | AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2'] | 2186 | AFC_HT_DATE_FIELDS = ['主借人日期', '共借人日期', '保证人日期1', '保证人日期2'] |
| 2164 | 2187 | ||
| 2165 | # MVC_OCR_FIELD = 'mvc_ocr' | 2188 | # MVC_OCR_FIELD = 'mvc_ocr' |
| ... | @@ -2188,6 +2211,8 @@ SE_COMPARE_FIELD = { | ... | @@ -2188,6 +2211,8 @@ SE_COMPARE_FIELD = { |
| 2188 | HIL_CONTRACT_1_EN: (HIL_CONTRACT_1_FIELD, HIL_CONTRACT_1_COMPARE_LOGIC, False), | 2211 | HIL_CONTRACT_1_EN: (HIL_CONTRACT_1_FIELD, HIL_CONTRACT_1_COMPARE_LOGIC, False), |
| 2189 | HIL_CONTRACT_2_EN: (HIL_CONTRACT_2_FIELD, HIL_CONTRACT_2_COMPARE_LOGIC, False), | 2212 | HIL_CONTRACT_2_EN: (HIL_CONTRACT_2_FIELD, HIL_CONTRACT_2_COMPARE_LOGIC, False), |
| 2190 | HIL_CONTRACT_3_EN: (HIL_CONTRACT_3_FIELD, HIL_CONTRACT_3_COMPARE_LOGIC, False), | 2213 | HIL_CONTRACT_3_EN: (HIL_CONTRACT_3_FIELD, HIL_CONTRACT_3_COMPARE_LOGIC, False), |
| 2214 | FS_EN: (FS_FIELD, FS_COMPARE_LOGIC, False), | ||
| 2215 | FSS_EN: (FSS_FIELD, FSS_COMPARE_LOGIC, False), | ||
| 2191 | } | 2216 | } |
| 2192 | 2217 | ||
| 2193 | SE_COMPARE_FIELD_AUTO = { | 2218 | SE_COMPARE_FIELD_AUTO = { | ... | ... |
| ... | @@ -336,6 +336,8 @@ class AFCOCRResult(models.Model): | ... | @@ -336,6 +336,8 @@ class AFCOCRResult(models.Model): |
| 336 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | 336 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
| 337 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") | 337 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") |
| 338 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | 338 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") |
| 339 | fs_ocr = models.TextField(null=True, verbose_name="财务报表") | ||
| 340 | fss_ocr = models.TextField(null=True, verbose_name="财务情况说明书") | ||
| 339 | 341 | ||
| 340 | 342 | ||
| 341 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 343 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
| ... | @@ -379,6 +381,8 @@ class HILOCRResult(models.Model): | ... | @@ -379,6 +381,8 @@ class HILOCRResult(models.Model): |
| 379 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | 381 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
| 380 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") | 382 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") |
| 381 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | 383 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") |
| 384 | fs_ocr = models.TextField(null=True, verbose_name="财务报表") | ||
| 385 | fss_ocr = models.TextField(null=True, verbose_name="财务情况说明书") | ||
| 382 | 386 | ||
| 383 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 387 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
| 384 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 388 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| ... | @@ -420,6 +424,8 @@ class AFCSEOCRResult(models.Model): | ... | @@ -420,6 +424,8 @@ class AFCSEOCRResult(models.Model): |
| 420 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | 424 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
| 421 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") | 425 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") |
| 422 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | 426 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") |
| 427 | fs_ocr = models.TextField(null=True, verbose_name="财务报表") | ||
| 428 | fss_ocr = models.TextField(null=True, verbose_name="财务情况说明书") | ||
| 423 | 429 | ||
| 424 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 430 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
| 425 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 431 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') |
| ... | @@ -461,6 +467,8 @@ class HILSEOCRResult(models.Model): | ... | @@ -461,6 +467,8 @@ class HILSEOCRResult(models.Model): |
| 461 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") | 467 | fsm_sc_ocr = models.TextField(null=True, verbose_name="汽车销售合同") |
| 462 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") | 468 | fsm_sc2_ocr = models.TextField(null=True, verbose_name="汽车销售合同补充合同") |
| 463 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") | 469 | fsm_activited = models.IntegerField(null=False, default=0, verbose_name="fsm激活状态 1:激活") |
| 470 | fs_ocr = models.TextField(null=True, verbose_name="财务报表") | ||
| 471 | fss_ocr = models.TextField(null=True, verbose_name="财务情况说明书") | ||
| 464 | 472 | ||
| 465 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') | 473 | update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') |
| 466 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | 474 | create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') | ... | ... |
| 1 | import json | 1 | import json |
| 2 | from multiprocessing.sharedctypes import Value | ||
| 2 | import os | 3 | import os |
| 3 | import cv2 | 4 | import cv2 |
| 4 | import time | 5 | import time |
| ... | @@ -934,6 +935,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -934,6 +935,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 934 | is_cdfl_bo = False # 车贷分离,主借 | 935 | is_cdfl_bo = False # 车贷分离,主借 |
| 935 | is_cdfl_co = False # 车贷分离,共借 | 936 | is_cdfl_co = False # 车贷分离,共借 |
| 936 | role_count = 0 | 937 | role_count = 0 |
| 938 | borrower_name = '' | ||
| 937 | # province = cms_info.get('province', '') | 939 | # province = cms_info.get('province', '') |
| 938 | for individual_info in cms_info.get('applicantInformation', []): | 940 | for individual_info in cms_info.get('applicantInformation', []): |
| 939 | role_count += 1 | 941 | role_count += 1 |
| ... | @@ -953,6 +955,16 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -953,6 +955,16 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 953 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: | 955 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: |
| 954 | is_cdfl_bo = True | 956 | is_cdfl_bo = True |
| 955 | 957 | ||
| 958 | # CHINARPA-4660 是否公户判断 | ||
| 959 | is_bo_corporate = False | ||
| 960 | customersubType = individual_info.get('customersubType', '') | ||
| 961 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and is_corporate: | ||
| 962 | is_bo_corporate = True | ||
| 963 | |||
| 964 | # CHINARPA-4660 财报主借人姓名赋值 | ||
| 965 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0]: | ||
| 966 | borrower_name = customer_name | ||
| 967 | |||
| 956 | for id_info in individual_info.get('IDInformation', []): | 968 | for id_info in individual_info.get('IDInformation', []): |
| 957 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: | 969 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: |
| 958 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] | 970 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] |
| ... | @@ -970,21 +982,22 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -970,21 +982,22 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 970 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', | 982 | # ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode', |
| 971 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] | 983 | # 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate'] |
| 972 | id_num = decode_des(id_info.get('idNum', ''), des_key) | 984 | id_num = decode_des(id_info.get('idNum', ''), des_key) |
| 973 | # bl_field_input = [ | 985 | bl_field_input = [ |
| 974 | # ('companyName', customer_name), | 986 | ('companyName', customer_name), |
| 975 | # ('legalRepName', legal_name), | 987 | ('legalRepName', legal_name), |
| 976 | # ('businessLicenseNo', id_num), | 988 | ('businessLicenseNo', id_num), |
| 977 | # ('organizationCreditCode', id_num), | 989 | ('organizationCreditCode', id_num), |
| 978 | # ('taxRegistrationCertificateNo', id_num), | 990 | ('taxRegistrationCertificateNo', id_num), |
| 979 | # ('businessLicenseDueDate', id_info.get('idExpiryDate', '')), | 991 | # ('businessLicenseDueDate', id_info.get('idExpiryDate', '')), |
| 980 | # ] | 992 | ] |
| 981 | 993 | ||
| 982 | if is_corporate: | 994 | if is_corporate: |
| 983 | company_info_list.append((customer_name, id_num, legal_name)) | 995 | company_info_list.append((customer_name, id_num, legal_name)) |
| 984 | # else: | 996 | else: |
| 985 | # bl_field_input.append(('establishmentDate', establishment_date)) | 997 | bl_field_input.append(('establishmentDate', establishment_date)) |
| 986 | 998 | ||
| 987 | # license_dict[consts.BL_EN] = bl_field_input | 999 | compare_log.info('{0} [bl_field_input] [{1}]'.format(log_base, bl_field_input)) |
| 1000 | license_dict[consts.BL_EN] = bl_field_input | ||
| 988 | all_id_num.append(id_num) | 1001 | all_id_num.append(id_num) |
| 989 | 1002 | ||
| 990 | # SME营业执照--------------------------------------------------------------------------------------------------- | 1003 | # SME营业执照--------------------------------------------------------------------------------------------------- |
| ... | @@ -1000,6 +1013,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1000,6 +1013,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 1000 | (customer_name, '、'.join(all_id_num), all_id_num[0]) | 1013 | (customer_name, '、'.join(all_id_num), all_id_num[0]) |
| 1001 | ) | 1014 | ) |
| 1002 | 1015 | ||
| 1016 | compare_log.info('{0} [license_dict] [{1}]'.format(log_base, license_dict)) | ||
| 1003 | if len(license_dict) > 0: | 1017 | if len(license_dict) > 0: |
| 1004 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) | 1018 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) |
| 1005 | 1019 | ||
| ... | @@ -1120,6 +1134,39 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1120,6 +1134,39 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 1120 | # vehicle_info[consts.UCI_EN] = vehicle_field_input | 1134 | # vehicle_info[consts.UCI_EN] = vehicle_field_input |
| 1121 | compare_info['vehicleInfo'] = vehicle_info | 1135 | compare_info['vehicleInfo'] = vehicle_info |
| 1122 | 1136 | ||
| 1137 | # 公户财务报表------------------------------------------------------------------------------------------------- | ||
| 1138 | financial_statement_info = {} | ||
| 1139 | financial_statement_input = [] | ||
| 1140 | corporateFinancialInformation = cms_info.get('corporateFinancialInformation', {}) | ||
| 1141 | hashCode = corporateFinancialInformation.get('hashCode', '') | ||
| 1142 | fiscalYear = corporateFinancialInformation.get('fiscalYear', '') | ||
| 1143 | totalAssets = corporateFinancialInformation.get('totaAssets', 0) | ||
| 1144 | totalLiabilitiesAndOwnersEquity = corporateFinancialInformation.get('totalLiabilitiesAndOwnersEquity', 0) | ||
| 1145 | netProfit = corporateFinancialInformation.get('netProfit', 0) | ||
| 1146 | if is_bo_corporate: | ||
| 1147 | financial_statement_input.append((consts.SE_FS_FIELD[0], hashCode)) | ||
| 1148 | financial_statement_input.append((consts.SE_FS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
| 1149 | financial_statement_input.append((consts.SE_FS_FIELD[2], fiscalYear)) | ||
| 1150 | financial_statement_input.append((consts.SE_FS_FIELD[3], [totalAssets, totalLiabilitiesAndOwnersEquity])) | ||
| 1151 | financial_statement_input.append((consts.SE_FS_FIELD[4], [netProfit])) | ||
| 1152 | financial_statement_info[consts.FS_EN] = financial_statement_input | ||
| 1153 | compare_info['financialStatementInfo'] = financial_statement_info | ||
| 1154 | |||
| 1155 | # 财报情况说明 | ||
| 1156 | financial_statement_supplementary_info = {} | ||
| 1157 | financial_statement_supplementary_input = [] | ||
| 1158 | cashAndCashEquivalentAtEndOfPeriod = corporateFinancialInformation.get('cashAndCashEquivalentAtEndOfPeriod', '') | ||
| 1159 | if cashAndCashEquivalentAtEndOfPeriod == '': | ||
| 1160 | need_fss = False | ||
| 1161 | else: | ||
| 1162 | need_fss = float(cashAndCashEquivalentAtEndOfPeriod) == 0 | ||
| 1163 | if is_bo_corporate and need_fss: | ||
| 1164 | financial_statement_supplementary_input.append((consts.SE_FSS_FIELD[0], borrower_name)) | ||
| 1165 | financial_statement_supplementary_input.append((consts.SE_FSS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
| 1166 | financial_statement_supplementary_info[consts.FSS_EN] = financial_statement_supplementary_input | ||
| 1167 | compare_info['financialStatementSupplementaryInfo'] = financial_statement_supplementary_info | ||
| 1168 | |||
| 1169 | |||
| 1123 | # 银行卡------------------------------------------------------------------------------------------------------- | 1170 | # 银行卡------------------------------------------------------------------------------------------------------- |
| 1124 | bank_info = {} | 1171 | bank_info = {} |
| 1125 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') | 1172 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') |
| ... | @@ -1375,7 +1422,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1375,7 +1422,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 1375 | if len(main_role_info[app_type]) >= id_idx+1: | 1422 | if len(main_role_info[app_type]) >= id_idx+1: |
| 1376 | is_find = True | 1423 | is_find = True |
| 1377 | if isinstance(field_idx, int): | 1424 | if isinstance(field_idx, int): |
| 1378 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 1425 | if key == '承租人签字' and is_bo_corporate: |
| 1426 | hil_contract_1_input.append((key, legal_name)) | ||
| 1427 | else: | ||
| 1428 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
| 1379 | else: | 1429 | else: |
| 1380 | hil_contract_1_input.append((key, field_idx)) | 1430 | hil_contract_1_input.append((key, field_idx)) |
| 1381 | if not is_find and is_force: | 1431 | if not is_find and is_force: |
| ... | @@ -1417,7 +1467,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1417,7 +1467,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 1417 | if len(main_role_info[app_type]) >= id_idx+1: | 1467 | if len(main_role_info[app_type]) >= id_idx+1: |
| 1418 | is_find = True | 1468 | is_find = True |
| 1419 | if isinstance(field_idx, int): | 1469 | if isinstance(field_idx, int): |
| 1420 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 1470 | if key == '抵押人签字' and is_bo_corporate: |
| 1471 | hil_contract_2_input.append((key, legal_name)) | ||
| 1472 | else: | ||
| 1473 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
| 1421 | else: | 1474 | else: |
| 1422 | hil_contract_2_input.append((key, field_idx)) | 1475 | hil_contract_2_input.append((key, field_idx)) |
| 1423 | if not is_find and is_force: | 1476 | if not is_find and is_force: |
| ... | @@ -1484,7 +1537,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d | ... | @@ -1484,7 +1537,10 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d |
| 1484 | if len(main_role_info[app_type]) >= id_idx+1: | 1537 | if len(main_role_info[app_type]) >= id_idx+1: |
| 1485 | is_find = True | 1538 | is_find = True |
| 1486 | if isinstance(field_idx, int): | 1539 | if isinstance(field_idx, int): |
| 1487 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 1540 | if (key == '借款人签字及时间' or key == '主借人签字') and is_bo_corporate: |
| 1541 | afc_contract_input.append((key, legal_name)) | ||
| 1542 | else: | ||
| 1543 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
| 1488 | else: | 1544 | else: |
| 1489 | afc_contract_input.append((key, field_idx)) | 1545 | afc_contract_input.append((key, field_idx)) |
| 1490 | if not is_find and is_force: | 1546 | if not is_find and is_force: |
| ... | @@ -1535,6 +1591,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1535,6 +1591,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 1535 | is_cdfl_bo = False # 车贷分离,主借 | 1591 | is_cdfl_bo = False # 车贷分离,主借 |
| 1536 | is_cdfl_co = False # 车贷分离,共借 | 1592 | is_cdfl_co = False # 车贷分离,共借 |
| 1537 | role_count = 0 | 1593 | role_count = 0 |
| 1594 | borrower_name = '' | ||
| 1538 | # province = cms_info.get('province', '') | 1595 | # province = cms_info.get('province', '') |
| 1539 | for individual_info in cms_info.get('applicantInformation', []): | 1596 | for individual_info in cms_info.get('applicantInformation', []): |
| 1540 | role_count += 1 | 1597 | role_count += 1 |
| ... | @@ -1554,6 +1611,16 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1554,6 +1611,16 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 1554 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: | 1611 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and not is_corporate: |
| 1555 | is_cdfl_bo = True | 1612 | is_cdfl_bo = True |
| 1556 | 1613 | ||
| 1614 | # CHINARPA-4660 是否公户判断 | ||
| 1615 | is_bo_corporate = False | ||
| 1616 | customersubType = individual_info.get('customersubType', '') | ||
| 1617 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0] and is_corporate: | ||
| 1618 | is_bo_corporate = True | ||
| 1619 | |||
| 1620 | # CHINARPA-4660 财报主借人姓名赋值 | ||
| 1621 | if individual_info['applicantType'] == consts.APPLICANT_TYPE_ORDER[0]: | ||
| 1622 | borrower_name = customer_name | ||
| 1623 | |||
| 1557 | for id_info in individual_info.get('IDInformation', []): | 1624 | for id_info in individual_info.get('IDInformation', []): |
| 1558 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: | 1625 | if id_info.get('idType') in consts.SE_CMS_FIRST_ID_FIELD_MAPPING: |
| 1559 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] | 1626 | license_en, is_prc = consts.SE_CMS_FIRST_ID_FIELD_MAPPING[id_info['idType']] |
| ... | @@ -1585,6 +1652,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1585,6 +1652,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 1585 | else: | 1652 | else: |
| 1586 | bl_field_input.append(('establishmentDate', establishment_date)) | 1653 | bl_field_input.append(('establishmentDate', establishment_date)) |
| 1587 | 1654 | ||
| 1655 | compare_log.info('{0} [bl_field_input] [{1}]'.format(log_base, bl_field_input)) | ||
| 1588 | license_dict[consts.BL_EN] = bl_field_input | 1656 | license_dict[consts.BL_EN] = bl_field_input |
| 1589 | all_id_num.append(id_num) | 1657 | all_id_num.append(id_num) |
| 1590 | 1658 | ||
| ... | @@ -1601,6 +1669,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1601,6 +1669,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 1601 | (customer_name, '、'.join(all_id_num), all_id_num[0]) | 1669 | (customer_name, '、'.join(all_id_num), all_id_num[0]) |
| 1602 | ) | 1670 | ) |
| 1603 | 1671 | ||
| 1672 | compare_log.info('{0} [license_dict] [{1}]'.format(log_base, license_dict)) | ||
| 1604 | if len(license_dict) > 0: | 1673 | if len(license_dict) > 0: |
| 1605 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) | 1674 | individual_info_dict.setdefault(individual_info['applicantType'], []).append(license_dict) |
| 1606 | 1675 | ||
| ... | @@ -1721,6 +1790,39 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1721,6 +1790,39 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 1721 | vehicle_info[consts.UCI_EN] = vehicle_field_input | 1790 | vehicle_info[consts.UCI_EN] = vehicle_field_input |
| 1722 | compare_info['vehicleInfo'] = vehicle_info | 1791 | compare_info['vehicleInfo'] = vehicle_info |
| 1723 | 1792 | ||
| 1793 | # 公户财务报表------------------------------------------------------------------------------------------------- | ||
| 1794 | financial_statement_info = {} | ||
| 1795 | financial_statement_input = [] | ||
| 1796 | corporateFinancialInformation = cms_info.get('corporateFinancialInformation', {}) | ||
| 1797 | hashCode = corporateFinancialInformation.get('hashCode', '') | ||
| 1798 | fiscalYear = corporateFinancialInformation.get('fiscalYear', '') | ||
| 1799 | totalAssets = corporateFinancialInformation.get('totaAssets', 0) | ||
| 1800 | totalLiabilitiesAndOwnersEquity = corporateFinancialInformation.get('totalLiabilitiesAndOwnersEquity', 0) | ||
| 1801 | netProfit = corporateFinancialInformation.get('netProfit', 0) | ||
| 1802 | if is_bo_corporate: | ||
| 1803 | financial_statement_input.append((consts.SE_FS_FIELD[0], hashCode)) | ||
| 1804 | financial_statement_input.append((consts.SE_FS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
| 1805 | financial_statement_input.append((consts.SE_FS_FIELD[2], fiscalYear)) | ||
| 1806 | financial_statement_input.append((consts.SE_FS_FIELD[3], [totalAssets, totalLiabilitiesAndOwnersEquity])) | ||
| 1807 | financial_statement_input.append((consts.SE_FS_FIELD[4], [netProfit])) | ||
| 1808 | financial_statement_info[consts.FS_EN] = financial_statement_input | ||
| 1809 | compare_info['financialStatementInfo'] = financial_statement_info | ||
| 1810 | |||
| 1811 | # 财报情况说明 | ||
| 1812 | financial_statement_supplementary_info = {} | ||
| 1813 | financial_statement_supplementary_input = [] | ||
| 1814 | cashAndCashEquivalentAtEndOfPeriod = corporateFinancialInformation.get('cashAndCashEquivalentAtEndOfPeriod', '') | ||
| 1815 | if cashAndCashEquivalentAtEndOfPeriod == '': | ||
| 1816 | need_fss = False | ||
| 1817 | else: | ||
| 1818 | need_fss = float(cashAndCashEquivalentAtEndOfPeriod) == 0 | ||
| 1819 | if is_bo_corporate and need_fss: | ||
| 1820 | financial_statement_supplementary_input.append((consts.SE_FSS_FIELD[0], borrower_name)) | ||
| 1821 | financial_statement_supplementary_input.append((consts.SE_FSS_FIELD[1], consts.SE_STAMP_VALUE)) | ||
| 1822 | financial_statement_supplementary_info[consts.FSS_EN] = financial_statement_supplementary_input | ||
| 1823 | compare_info['financialStatementSupplementaryInfo'] = financial_statement_supplementary_info | ||
| 1824 | |||
| 1825 | |||
| 1724 | # 银行卡------------------------------------------------------------------------------------------------------- | 1826 | # 银行卡------------------------------------------------------------------------------------------------------- |
| 1725 | bank_info = {} | 1827 | bank_info = {} |
| 1726 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') | 1828 | bank_name = cms_info.get('bankAccountDetails', {}).get('bankName', '') |
| ... | @@ -1939,7 +2041,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1939,7 +2041,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 1939 | if len(main_role_info[app_type]) >= id_idx+1: | 2041 | if len(main_role_info[app_type]) >= id_idx+1: |
| 1940 | is_find = True | 2042 | is_find = True |
| 1941 | if isinstance(field_idx, int): | 2043 | if isinstance(field_idx, int): |
| 1942 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 2044 | if key == '承租人签字' and is_bo_corporate: |
| 2045 | hil_contract_1_input.append((key, legal_name)) | ||
| 2046 | else: | ||
| 2047 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
| 1943 | else: | 2048 | else: |
| 1944 | hil_contract_1_input.append((key, field_idx)) | 2049 | hil_contract_1_input.append((key, field_idx)) |
| 1945 | if not is_find and is_force: | 2050 | if not is_find and is_force: |
| ... | @@ -1958,7 +2063,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1958,7 +2063,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 1958 | (consts.SE_HIL_CON_3_FIELD[6], main_id), | 2063 | (consts.SE_HIL_CON_3_FIELD[6], main_id), |
| 1959 | ] | 2064 | ] |
| 1960 | if online_sign: | 2065 | if online_sign: |
| 1961 | hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], main_name)) | 2066 | if is_bo_corporate: |
| 2067 | hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], legal_name)) | ||
| 2068 | else: | ||
| 2069 | hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], main_name)) | ||
| 1962 | contract_info[consts.HIL_CONTRACT_3_EN] = hil_contract_3_input | 2070 | contract_info[consts.HIL_CONTRACT_3_EN] = hil_contract_3_input |
| 1963 | 2071 | ||
| 1964 | # HIL合同 车辆租赁抵押合同 -------------------------------------------------------------------------------------- | 2072 | # HIL合同 车辆租赁抵押合同 -------------------------------------------------------------------------------------- |
| ... | @@ -1981,7 +2089,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -1981,7 +2089,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 1981 | if len(main_role_info[app_type]) >= id_idx+1: | 2089 | if len(main_role_info[app_type]) >= id_idx+1: |
| 1982 | is_find = True | 2090 | is_find = True |
| 1983 | if isinstance(field_idx, int): | 2091 | if isinstance(field_idx, int): |
| 1984 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 2092 | if key == '抵押人签字' and is_bo_corporate: |
| 2093 | hil_contract_2_input.append((key, legal_name)) | ||
| 2094 | else: | ||
| 2095 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
| 1985 | else: | 2096 | else: |
| 1986 | hil_contract_2_input.append((key, field_idx)) | 2097 | hil_contract_2_input.append((key, field_idx)) |
| 1987 | if not is_find and is_force: | 2098 | if not is_find and is_force: |
| ... | @@ -2048,7 +2159,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect | ... | @@ -2048,7 +2159,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect |
| 2048 | if len(main_role_info[app_type]) >= id_idx+1: | 2159 | if len(main_role_info[app_type]) >= id_idx+1: |
| 2049 | is_find = True | 2160 | is_find = True |
| 2050 | if isinstance(field_idx, int): | 2161 | if isinstance(field_idx, int): |
| 2051 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | 2162 | if (key == '借款人签字及时间' or key == '主借人签字') and is_bo_corporate: |
| 2163 | afc_contract_input.append((key, legal_name)) | ||
| 2164 | else: | ||
| 2165 | afc_contract_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
| 2052 | else: | 2166 | else: |
| 2053 | afc_contract_input.append((key, field_idx)) | 2167 | afc_contract_input.append((key, field_idx)) |
| 2054 | if not is_find and is_force: | 2168 | if not is_find and is_force: |
| ... | @@ -2346,6 +2460,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2346,6 +2460,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
| 2346 | section_img_info = dict() | 2460 | section_img_info = dict() |
| 2347 | field_img_path_dict = dict() | 2461 | field_img_path_dict = dict() |
| 2348 | ocr_res_str = ocr_res_dict.get(ocr_field) | 2462 | ocr_res_str = ocr_res_dict.get(ocr_field) |
| 2463 | compare_log.info('{0} [{1}_compare] ocr_res:{2}'.format(log_base, license_en, ocr_res_str)) | ||
| 2349 | if ocr_res_str is not None: | 2464 | if ocr_res_str is not None: |
| 2350 | ocr_res_list = json.loads(ocr_res_str) | 2465 | ocr_res_list = json.loads(ocr_res_str) |
| 2351 | 2466 | ||
| ... | @@ -2395,11 +2510,17 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2395,11 +2510,17 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
| 2395 | 2510 | ||
| 2396 | if isinstance(ocr_str, str): | 2511 | if isinstance(ocr_str, str): |
| 2397 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 2512 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
| 2513 | compare_log.info('{0} [{1}_license] [field:{2}] [input_str:{3}] [ocr_str:{4}] [result:{5}]'.format(log_base, license_en, name, value, ocr_str, result)) | ||
| 2398 | no_key = False | 2514 | no_key = False |
| 2399 | # 二手车交易凭证 日期 | 2515 | # 二手车交易凭证 日期 |
| 2400 | elif ocr_field == consts.JYPZ_OCR_FIELD and name == consts.SE_GB_USED_FIELD[2]: | 2516 | elif ocr_field == consts.JYPZ_OCR_FIELD and name == consts.SE_GB_USED_FIELD[2]: |
| 2401 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | 2517 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) |
| 2402 | no_key = False | 2518 | no_key = False |
| 2519 | elif isinstance(ocr_str, int): | ||
| 2520 | # 目前应该只有财报的公章 | ||
| 2521 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
| 2522 | compare_log.info('{0} [{1}_license] [field:{2}] [input_str:{3}] [ocr_str:{4}] [result:{5}]'.format(log_base, license_en, name, value, ocr_str, result)) | ||
| 2523 | no_key = False | ||
| 2403 | else: | 2524 | else: |
| 2404 | result = consts.RESULT_N | 2525 | result = consts.RESULT_N |
| 2405 | ocr_str = empty_str | 2526 | ocr_str = empty_str |
| ... | @@ -2523,6 +2644,113 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -2523,6 +2644,113 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
| 2523 | 2644 | ||
| 2524 | return result_field_list, no_ocr_result, field_img_path_dict | 2645 | return result_field_list, no_ocr_result, field_img_path_dict |
| 2525 | 2646 | ||
| 2647 | def se_fs_compare(license_en, ocr_res_dict, field_list): | ||
| 2648 | compare_log.info('{0} [se_fs_compare] start'.format(log_base)) | ||
| 2649 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | ||
| 2650 | |||
| 2651 | is_find = False | ||
| 2652 | no_ocr_result = False | ||
| 2653 | special_expiry_date_slice = False | ||
| 2654 | result_field_list = [] | ||
| 2655 | section_img_info = dict() | ||
| 2656 | field_img_path_dict = dict() | ||
| 2657 | ocr_res_str = ocr_res_dict.get(ocr_field) | ||
| 2658 | compare_log.info('{0} [se_fs_compare] ocr_res:{1}'.format(log_base, ocr_res_str)) | ||
| 2659 | if ocr_res_str is not None: | ||
| 2660 | ocr_res_list = json.loads(ocr_res_str) | ||
| 2661 | |||
| 2662 | length = len(ocr_res_list) | ||
| 2663 | |||
| 2664 | last_ocr_str = ocr_res_list[length-1] | ||
| 2665 | compare_log.info('{0} [se_fs_compare] [code len {1}] [stamp len {2}] ]'.format(log_base, len(last_ocr_str.get('code',{})), len(last_ocr_str.get('stamp',{})))) | ||
| 2666 | |||
| 2667 | if len(last_ocr_str.get('code',{})) != 3 or len(last_ocr_str.get('stamp',{})) != 3: | ||
| 2668 | # 先判断最后一次上传的文件是不是包括3个,如果不是直接返回"未提供财报或财报不完整" | ||
| 2669 | compare_log.info('{0} [se_fs_compare error] last ocr result len < 3'.format(log_base)) | ||
| 2670 | else: | ||
| 2671 | for res_idx in range(length-1, -1, -1): | ||
| 2672 | if is_find: | ||
| 2673 | break | ||
| 2674 | |||
| 2675 | for idx, (name, value) in enumerate(field_list): | ||
| 2676 | compare_log.info('{0} [se_fs_compare for ... in] [idx:{1}] [name:{2}] [value:{3}]'.format(log_base, idx, name, value)) | ||
| 2677 | ocr_str = ocr_res_list[res_idx].get(compare_logic[name][0]) | ||
| 2678 | compare_log.info('{0} [se_fs_compare ocr_str] [ocr_str:{1}]'.format(log_base, ocr_str)) | ||
| 2679 | #财年/资产负债表内容/利润表内容 不需要ocr结果,所以即使为空也可以进入比对 | ||
| 2680 | if isinstance(ocr_str, str) or isinstance(ocr_str, dict) or compare_logic[name][0] == '财年' or compare_logic[name][0] == '资产负债表内容' or compare_logic[name][0] == '利润表内容': | ||
| 2681 | result = getattr(cp, compare_logic[name][1])(value, ocr_str, **compare_logic[name][2]) | ||
| 2682 | compare_log.info('{0} [se_fs_compare result:{1}]'.format(log_base, result)) | ||
| 2683 | no_key = False | ||
| 2684 | else: | ||
| 2685 | result = consts.RESULT_N | ||
| 2686 | ocr_str = empty_str | ||
| 2687 | no_key = True | ||
| 2688 | |||
| 2689 | if idx == 0 and result == consts.RESULT_N and length > 1: | ||
| 2690 | break | ||
| 2691 | |||
| 2692 | is_find = True | ||
| 2693 | section_img_info[consts.SECTION_IMG_PATH_KEY] = ocr_res_list[res_idx].get(consts.SECTION_IMG_PATH_KEY, '') | ||
| 2694 | section_img_info[consts.ALL_POSITION_KEY] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY, {}) | ||
| 2695 | if special_expiry_date: | ||
| 2696 | section_img_info[consts.SECTION_IMG_PATH_KEY_2] = ocr_res_list[res_idx].get( | ||
| 2697 | consts.SECTION_IMG_PATH_KEY_2, '') | ||
| 2698 | section_img_info[consts.ALL_POSITION_KEY_2] = ocr_res_list[res_idx].get(consts.ALL_POSITION_KEY_2, {}) | ||
| 2699 | |||
| 2700 | img_path = ocr_res_list[res_idx].get(consts.IMG_PATH_KEY, '') if result == consts.RESULT_N else empty_str | ||
| 2701 | if isinstance(value, list): | ||
| 2702 | value = json.dumps(value, ensure_ascii=False) | ||
| 2703 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
| 2704 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) | ||
| 2705 | else: | ||
| 2706 | no_ocr_result = True | ||
| 2707 | |||
| 2708 | if not is_find: | ||
| 2709 | for name, value in field_list: | ||
| 2710 | if isinstance(value, list): | ||
| 2711 | value = json.dumps(value, ensure_ascii=False) | ||
| 2712 | no_find_str = consts.FS_NO_FIND | ||
| 2713 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, no_find_str)) | ||
| 2714 | |||
| 2715 | if is_find: | ||
| 2716 | section_img_path = section_img_info.get(consts.SECTION_IMG_PATH_KEY, '') | ||
| 2717 | if os.path.exists(section_img_path): | ||
| 2718 | failed_field = [] | ||
| 2719 | base_img_path = empty_str | ||
| 2720 | for name, _, result, _, img_path, _, _ in result_field_list: | ||
| 2721 | if result == consts.RESULT_N: | ||
| 2722 | if special_expiry_date_slice and name == 'idExpiryDate': | ||
| 2723 | continue | ||
| 2724 | failed_field.append(name) | ||
| 2725 | if base_img_path == empty_str: | ||
| 2726 | base_img_path = img_path | ||
| 2727 | if len(failed_field) > 0: | ||
| 2728 | info = section_img_info.get(consts.ALL_POSITION_KEY, {}) | ||
| 2729 | section_position = info.get(consts.POSITION_KEY, {}) | ||
| 2730 | section_angle = info.get(consts.ANGLE_KEY, 0) | ||
| 2731 | try: | ||
| 2732 | last_img = img_process(section_img_path, section_position, section_angle) | ||
| 2733 | except Exception as e: | ||
| 2734 | for field in failed_field: | ||
| 2735 | field_img_path_dict[field] = base_img_path | ||
| 2736 | else: | ||
| 2737 | pre, suf = os.path.splitext(section_img_path) | ||
| 2738 | for field in failed_field: | ||
| 2739 | try: | ||
| 2740 | res_field = compare_logic[field][0] | ||
| 2741 | is_valid, coord_tuple = field_build_coordinates(info.get(res_field, {})) | ||
| 2742 | if is_valid: | ||
| 2743 | save_path = '{0}_{1}{2}'.format(pre, field, suf) | ||
| 2744 | field_img = last_img[coord_tuple[0]:coord_tuple[1], coord_tuple[2]:coord_tuple[3], :] | ||
| 2745 | cv2.imwrite(save_path, field_img) | ||
| 2746 | field_img_path_dict[field] = save_path | ||
| 2747 | else: | ||
| 2748 | field_img_path_dict[field] = base_img_path | ||
| 2749 | except Exception as e: | ||
| 2750 | field_img_path_dict[field] = base_img_path | ||
| 2751 | |||
| 2752 | return result_field_list, field_img_path_dict | ||
| 2753 | |||
| 2526 | 2754 | ||
| 2527 | def se_compare_license_id(license_en, id_res_list, field_list, is_auto): | 2755 | def se_compare_license_id(license_en, id_res_list, field_list, is_auto): |
| 2528 | if is_auto: | 2756 | if is_auto: |
| ... | @@ -3023,9 +3251,11 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3023,9 +3251,11 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
| 3023 | rpa_failure_reason = {} | 3251 | rpa_failure_reason = {} |
| 3024 | field_result_dict = {} | 3252 | field_result_dict = {} |
| 3025 | 3253 | ||
| 3254 | # compare_info 格式: {'financialStatementInfo': {'Financial Statement': [('11', '22'), ('111', '222'), ('1111', '2222')]}} | ||
| 3026 | for info_key, info_value in compare_info.items(): | 3255 | for info_key, info_value in compare_info.items(): |
| 3027 | if info_key in ['individualCusInfo', 'applicantInformation']: | 3256 | if info_key in ['individualCusInfo', 'applicantInformation']: |
| 3028 | for idx, license_list in info_value.items(): | 3257 | for idx, license_list in info_value.items(): |
| 3258 | compare_log.info('{0} [compare license_list] [entity={1}]'.format(log_base, license_list)) | ||
| 3029 | for license_dict in license_list: | 3259 | for license_dict in license_list: |
| 3030 | for license_en, field_list in license_dict.items(): | 3260 | for license_en, field_list in license_dict.items(): |
| 3031 | strip_list = [] | 3261 | strip_list = [] |
| ... | @@ -3081,6 +3311,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3081,6 +3311,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
| 3081 | each_license_failed_count, len(result_field_list))) | 3311 | each_license_failed_count, len(result_field_list))) |
| 3082 | else: | 3312 | else: |
| 3083 | for license_en, field_list in info_value.items(): | 3313 | for license_en, field_list in info_value.items(): |
| 3314 | compare_log.info('{0} [compare license_en] [entity={1}]'.format(log_base, license_en)) | ||
| 3084 | strip_list = [] | 3315 | strip_list = [] |
| 3085 | for a, b in field_list: | 3316 | for a, b in field_list: |
| 3086 | if isinstance(b, str): | 3317 | if isinstance(b, str): |
| ... | @@ -3104,6 +3335,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list | ... | @@ -3104,6 +3335,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list |
| 3104 | result_field_list, field_img_path_dict = se_contract_qrs_compare(license_en, ocr_res_dict, strip_list) | 3335 | result_field_list, field_img_path_dict = se_contract_qrs_compare(license_en, ocr_res_dict, strip_list) |
| 3105 | elif license_en == consts.BS_EN: | 3336 | elif license_en == consts.BS_EN: |
| 3106 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type) | 3337 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type) |
| 3338 | elif license_en == consts.FS_EN: | ||
| 3339 | result_field_list, field_img_path_dict = se_fs_compare(license_en, ocr_res_dict, strip_list) | ||
| 3107 | else: | 3340 | else: |
| 3108 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) | 3341 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) |
| 3109 | 3342 | ... | ... |
| ... | @@ -704,5 +704,58 @@ class Comparison: | ... | @@ -704,5 +704,58 @@ class Comparison: |
| 704 | except Exception as e: | 704 | except Exception as e: |
| 705 | return self.RESULT_N | 705 | return self.RESULT_N |
| 706 | 706 | ||
| 707 | def hash_code_compare(self, input_str, ocr_dict, **kwargs): | ||
| 708 | try: | ||
| 709 | balance_sheet_hash = ocr_dict.get('balance_sheet','') | ||
| 710 | income_statement_hash = ocr_dict.get('income_statement','') | ||
| 711 | cash_flow_statement_hash = ocr_dict.get('cash_flow_statement','') | ||
| 712 | if balance_sheet_hash != input_str or income_statement_hash != input_str or cash_flow_statement_hash != input_str: | ||
| 713 | return self.RESULT_N | ||
| 714 | else: | ||
| 715 | return self.RESULT_Y | ||
| 716 | except Exception as e: | ||
| 717 | return self.RESULT_N | ||
| 718 | |||
| 719 | def stamp_dict_compare(self, input_str, ocr_dict, **kwargs): | ||
| 720 | try: | ||
| 721 | balance_sheet_stamp = ocr_dict.get('balance_sheet','') | ||
| 722 | income_statement_stamp = ocr_dict.get('income_statement','') | ||
| 723 | cash_flow_statement_stamp = ocr_dict.get('cash_flow_statement','') | ||
| 724 | if balance_sheet_stamp != 1 or income_statement_stamp != 1 or cash_flow_statement_stamp != 1: | ||
| 725 | return self.RESULT_N | ||
| 726 | else: | ||
| 727 | return self.RESULT_Y | ||
| 728 | except Exception as e: | ||
| 729 | return self.RESULT_N | ||
| 730 | |||
| 731 | def stamp_str_compare(self, input_str, ocr_str, **kwargs): | ||
| 732 | try: | ||
| 733 | if ocr_str != 1: | ||
| 734 | return self.RESULT_N | ||
| 735 | else: | ||
| 736 | return self.RESULT_Y | ||
| 737 | except Exception as e: | ||
| 738 | return self.RESULT_N | ||
| 739 | |||
| 740 | def fiscal_year_compare(self, input_str, ocr_list, **kwargs): | ||
| 741 | try: | ||
| 742 | this_year_str = datetime.now().strftime('%Y') | ||
| 743 | this_year = int(this_year_str) | ||
| 744 | last_year = this_year - 1 | ||
| 745 | if str(input_str) != str(this_year) and str(input_str) != str(last_year): | ||
| 746 | return self.RESULT_N | ||
| 747 | return self.RESULT_Y | ||
| 748 | except Exception as e: | ||
| 749 | return self.RESULT_N | ||
| 750 | |||
| 751 | def input_list_not_zero_compare(self, input_list, ocr_list, **kwargs): | ||
| 752 | try: | ||
| 753 | for item in input_list: | ||
| 754 | if float(item) == 0: | ||
| 755 | return self.RESULT_N | ||
| 756 | return self.RESULT_Y | ||
| 757 | except Exception as e: | ||
| 758 | return self.RESULT_N | ||
| 759 | |||
| 707 | 760 | ||
| 708 | cp = Comparison() | 761 | cp = Comparison() | ... | ... |
src/common/tools/mssql_script28.py
0 → 100644
| 1 | import pyodbc | ||
| 2 | |||
| 3 | hil_sql = """ | ||
| 4 | ALTER TABLE hil_ocr_result ADD fs_ocr nvarchar(max); | ||
| 5 | ALTER TABLE hil_se_ocr_result ADD fs_ocr nvarchar(max); | ||
| 6 | ALTER TABLE hil_ocr_result ADD fss_ocr nvarchar(max); | ||
| 7 | ALTER TABLE hil_se_ocr_result ADD fss_ocr nvarchar(max); | ||
| 8 | """ | ||
| 9 | |||
| 10 | afc_sql = """ | ||
| 11 | ALTER TABLE afc_ocr_result ADD fs_ocr nvarchar(max); | ||
| 12 | ALTER TABLE afc_se_ocr_result ADD fs_ocr nvarchar(max); | ||
| 13 | ALTER TABLE afc_ocr_result ADD fss_ocr nvarchar(max); | ||
| 14 | ALTER TABLE afc_se_ocr_result ADD fss_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