Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
a0d6443d
authored
2024-08-16 16:43:06 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'feature/CHINARPA-4660'
2 parents
c811f8ce
62a7558f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
368 additions
and
18 deletions
src/apps/doc/consts.py
src/apps/doc/models.py
src/celery_compare/tasks.py
src/common/tools/comparison.py
src/common/tools/mssql_script28.py
src/apps/doc/consts.py
View file @
a0d6443
...
...
@@ -1248,6 +1248,8 @@ FSM_CONTRACT_WEP_FIELD = 'fsm_wep_ocr'
FSM_CONTRACT_MSI_FIELD
=
'fsm_msi_ocr'
FSM_CONTRACT_SC_FIELD
=
'fsm_sc_ocr'
FSM_CONTRACT_SC2_FIELD
=
'fsm_sc2_ocr'
FS_FIELD
=
'fs_ocr'
FSS_FIELD
=
'fss_ocr'
BS_CLASSIFY
=
10089
...
...
@@ -1304,6 +1306,8 @@ COMPARE_FIELDS = (
HIL_CONTRACT_1_FIELD
,
HIL_CONTRACT_2_FIELD
,
HIL_CONTRACT_3_FIELD
,
FS_FIELD
,
FSS_FIELD
,
)
PRE_COMPARE_FIELDS
=
(
...
...
@@ -1505,6 +1509,8 @@ SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '
JDMPV_VALUE
=
[
'-'
,
'--'
,
'0
%
'
,
'0.00'
,
'/'
,
'0'
,
''
]
JYPZ_TYPE_1
=
[
'二手车交易凭证'
]
JYPZ_TYPE_2
=
[
'BMW官方认证二手车交易凭证'
,
'二手车交易凭证'
]
SE_FS_FIELD
=
[
'Hash值'
,
'公章'
,
'财年'
,
'资产负债表内容'
,
'利润表内容'
]
SE_FSS_FIELD
=
[
'公司名称'
,
'公章'
]
SE_BANK_FIELD
=
[
'accountNo'
,
'bankName'
]
SE_DDA_FIELD
=
[
'applicationId(1)'
,
'applicationId(2)'
,
'bankName'
,
'companyName'
,
'customerName'
,
'idNum'
,
'accountHolderName'
,
'accountNo'
]
...
...
@@ -1818,8 +1824,11 @@ BS_EN = 'Bank Statement'
HIL_CONTRACT_1_EN
=
'售后回租合同'
HIL_CONTRACT_2_EN
=
'车辆租赁抵押合同'
HIL_CONTRACT_3_EN
=
'车辆处置协议'
FS_EN
=
'Financial Statement'
FSS_EN
=
'Financial Statement Supplementary'
DDA_NO_FIND
=
'需人工查看DDA或截图'
FS_NO_FIND
=
'未提供财报或财报不完整'
SKIP_CARD
=
{
SME_BL_EN
}
...
...
@@ -2160,6 +2169,20 @@ HT_COMPARE_LOGIC = {
'无ASP产品'
:
(
'无ASP产品'
,
'se_self_compare_other_asp'
,
{},
GZS_REASON_1
),
}
# 格式:'xueao给的excel字段名':('数据库字段名','比对逻辑','特殊处理可以忽略','比对不合格时的返回内容')
FS_COMPARE_LOGIC
=
{
'Hash值'
:
(
'code'
,
'hash_code_compare'
,
{},
'财报Hash值与系统不一致'
),
'公章'
:
(
'stamp'
,
'stamp_dict_compare'
,
{},
'财报无公章'
),
'财年'
:
(
'财年'
,
'fiscal_year_compare'
,
{},
'财报所属财年错误'
),
'资产负债表内容'
:
(
'资产负债表内容'
,
'input_list_not_zero_compare'
,
{},
'财报资产负债表为空'
),
'利润表内容'
:
(
'利润表内容'
,
'input_list_not_zero_compare'
,
{},
'财报利润表为空'
),
}
FSS_COMPARE_LOGIC
=
{
'公司名称'
:
(
'title'
,
'se_company_compare'
,
{},
'财报情况说明公司名称错误'
),
'公章'
:
(
'stamp'
,
'stamp_str_compare'
,
{},
'财报情况说明无公章'
),
}
AFC_HT_DATE_FIELDS
=
[
'主借人日期'
,
'共借人日期'
,
'保证人日期1'
,
'保证人日期2'
]
# MVC_OCR_FIELD = 'mvc_ocr'
...
...
@@ -2188,6 +2211,8 @@ SE_COMPARE_FIELD = {
HIL_CONTRACT_1_EN
:
(
HIL_CONTRACT_1_FIELD
,
HIL_CONTRACT_1_COMPARE_LOGIC
,
False
),
HIL_CONTRACT_2_EN
:
(
HIL_CONTRACT_2_FIELD
,
HIL_CONTRACT_2_COMPARE_LOGIC
,
False
),
HIL_CONTRACT_3_EN
:
(
HIL_CONTRACT_3_FIELD
,
HIL_CONTRACT_3_COMPARE_LOGIC
,
False
),
FS_EN
:
(
FS_FIELD
,
FS_COMPARE_LOGIC
,
False
),
FSS_EN
:
(
FSS_FIELD
,
FSS_COMPARE_LOGIC
,
False
),
}
SE_COMPARE_FIELD_AUTO
=
{
...
...
src/apps/doc/models.py
View file @
a0d6443
...
...
@@ -336,6 +336,8 @@ class AFCOCRResult(models.Model):
fsm_sc_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"汽车销售合同"
)
fsm_sc2_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"汽车销售合同补充合同"
)
fsm_activited
=
models
.
IntegerField
(
null
=
False
,
default
=
0
,
verbose_name
=
"fsm激活状态 1:激活"
)
fs_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"财务报表"
)
fss_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"财务情况说明书"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
...
...
@@ -379,6 +381,8 @@ class HILOCRResult(models.Model):
fsm_sc_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"汽车销售合同"
)
fsm_sc2_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"汽车销售合同补充合同"
)
fsm_activited
=
models
.
IntegerField
(
null
=
False
,
default
=
0
,
verbose_name
=
"fsm激活状态 1:激活"
)
fs_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"财务报表"
)
fss_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"财务情况说明书"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
...
...
@@ -420,6 +424,8 @@ class AFCSEOCRResult(models.Model):
fsm_sc_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"汽车销售合同"
)
fsm_sc2_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"汽车销售合同补充合同"
)
fsm_activited
=
models
.
IntegerField
(
null
=
False
,
default
=
0
,
verbose_name
=
"fsm激活状态 1:激活"
)
fs_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"财务报表"
)
fss_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"财务情况说明书"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
...
...
@@ -461,6 +467,8 @@ class HILSEOCRResult(models.Model):
fsm_sc_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"汽车销售合同"
)
fsm_sc2_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"汽车销售合同补充合同"
)
fsm_activited
=
models
.
IntegerField
(
null
=
False
,
default
=
0
,
verbose_name
=
"fsm激活状态 1:激活"
)
fs_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"财务报表"
)
fss_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"财务情况说明书"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
...
...
src/celery_compare/tasks.py
View file @
a0d6443
import
json
from
multiprocessing.sharedctypes
import
Value
import
os
import
cv2
import
time
...
...
@@ -934,6 +935,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d
is_cdfl_bo
=
False
# 车贷分离,主借
is_cdfl_co
=
False
# 车贷分离,共借
role_count
=
0
borrower_name
=
''
# province = cms_info.get('province', '')
for
individual_info
in
cms_info
.
get
(
'applicantInformation'
,
[]):
role_count
+=
1
...
...
@@ -953,6 +955,16 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d
if
individual_info
[
'applicantType'
]
==
consts
.
APPLICANT_TYPE_ORDER
[
0
]
and
not
is_corporate
:
is_cdfl_bo
=
True
# CHINARPA-4660 是否公户判断
is_bo_corporate
=
False
customersubType
=
individual_info
.
get
(
'customersubType'
,
''
)
if
individual_info
[
'applicantType'
]
==
consts
.
APPLICANT_TYPE_ORDER
[
0
]
and
is_corporate
:
is_bo_corporate
=
True
# CHINARPA-4660 财报主借人姓名赋值
if
individual_info
[
'applicantType'
]
==
consts
.
APPLICANT_TYPE_ORDER
[
0
]:
borrower_name
=
customer_name
for
id_info
in
individual_info
.
get
(
'IDInformation'
,
[]):
if
id_info
.
get
(
'idType'
)
in
consts
.
SE_CMS_FIRST_ID_FIELD_MAPPING
:
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
# ['companyName', 'legalRepName', 'businessLicenseNo', 'organizationCreditCode',
# 'taxRegistrationCertificateNo', 'establishmentDate', 'businessLicenseDueDate']
id_num
=
decode_des
(
id_info
.
get
(
'idNum'
,
''
),
des_key
)
#
bl_field_input = [
#
('companyName', customer_name),
#
('legalRepName', legal_name),
#
('businessLicenseNo', id_num),
#
('organizationCreditCode', id_num),
#
('taxRegistrationCertificateNo', id_num),
#
('businessLicenseDueDate', id_info.get('idExpiryDate', '')),
#
]
bl_field_input
=
[
(
'companyName'
,
customer_name
),
(
'legalRepName'
,
legal_name
),
(
'businessLicenseNo'
,
id_num
),
(
'organizationCreditCode'
,
id_num
),
(
'taxRegistrationCertificateNo'
,
id_num
),
#
('businessLicenseDueDate', id_info.get('idExpiryDate', '')),
]
if
is_corporate
:
company_info_list
.
append
((
customer_name
,
id_num
,
legal_name
))
#
else:
#
bl_field_input.append(('establishmentDate', establishment_date))
else
:
bl_field_input
.
append
((
'establishmentDate'
,
establishment_date
))
# license_dict[consts.BL_EN] = bl_field_input
compare_log
.
info
(
'{0} [bl_field_input] [{1}]'
.
format
(
log_base
,
bl_field_input
))
license_dict
[
consts
.
BL_EN
]
=
bl_field_input
all_id_num
.
append
(
id_num
)
# SME营业执照---------------------------------------------------------------------------------------------------
...
...
@@ -1000,6 +1013,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d
(
customer_name
,
'、'
.
join
(
all_id_num
),
all_id_num
[
0
])
)
compare_log
.
info
(
'{0} [license_dict] [{1}]'
.
format
(
log_base
,
license_dict
))
if
len
(
license_dict
)
>
0
:
individual_info_dict
.
setdefault
(
individual_info
[
'applicantType'
],
[])
.
append
(
license_dict
)
...
...
@@ -1120,6 +1134,39 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d
# vehicle_info[consts.UCI_EN] = vehicle_field_input
compare_info
[
'vehicleInfo'
]
=
vehicle_info
# 公户财务报表-------------------------------------------------------------------------------------------------
financial_statement_info
=
{}
financial_statement_input
=
[]
corporateFinancialInformation
=
cms_info
.
get
(
'corporateFinancialInformation'
,
{})
hashCode
=
corporateFinancialInformation
.
get
(
'hashCode'
,
''
)
fiscalYear
=
corporateFinancialInformation
.
get
(
'fiscalYear'
,
''
)
totalAssets
=
corporateFinancialInformation
.
get
(
'totaAssets'
,
0
)
totalLiabilitiesAndOwnersEquity
=
corporateFinancialInformation
.
get
(
'totalLiabilitiesAndOwnersEquity'
,
0
)
netProfit
=
corporateFinancialInformation
.
get
(
'netProfit'
,
0
)
if
is_bo_corporate
:
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
0
],
hashCode
))
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
1
],
consts
.
SE_STAMP_VALUE
))
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
2
],
fiscalYear
))
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
3
],
[
totalAssets
,
totalLiabilitiesAndOwnersEquity
]))
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
4
],
[
netProfit
]))
financial_statement_info
[
consts
.
FS_EN
]
=
financial_statement_input
compare_info
[
'financialStatementInfo'
]
=
financial_statement_info
# 财报情况说明
financial_statement_supplementary_info
=
{}
financial_statement_supplementary_input
=
[]
cashAndCashEquivalentAtEndOfPeriod
=
corporateFinancialInformation
.
get
(
'cashAndCashEquivalentAtEndOfPeriod'
,
''
)
if
cashAndCashEquivalentAtEndOfPeriod
==
''
:
need_fss
=
False
else
:
need_fss
=
float
(
cashAndCashEquivalentAtEndOfPeriod
)
==
0
if
is_bo_corporate
and
need_fss
:
financial_statement_supplementary_input
.
append
((
consts
.
SE_FSS_FIELD
[
0
],
borrower_name
))
financial_statement_supplementary_input
.
append
((
consts
.
SE_FSS_FIELD
[
1
],
consts
.
SE_STAMP_VALUE
))
financial_statement_supplementary_info
[
consts
.
FSS_EN
]
=
financial_statement_supplementary_input
compare_info
[
'financialStatementSupplementaryInfo'
]
=
financial_statement_supplementary_info
# 银行卡-------------------------------------------------------------------------------------------------------
bank_info
=
{}
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
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
hil_contract_1_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
if
key
==
'承租人签字'
and
is_bo_corporate
:
hil_contract_1_input
.
append
((
key
,
legal_name
))
else
:
hil_contract_1_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
hil_contract_1_input
.
append
((
key
,
field_idx
))
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
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
hil_contract_2_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
if
key
==
'抵押人签字'
and
is_bo_corporate
:
hil_contract_2_input
.
append
((
key
,
legal_name
))
else
:
hil_contract_2_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
hil_contract_2_input
.
append
((
key
,
field_idx
))
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
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
afc_contract_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
if
(
key
==
'借款人签字及时间'
or
key
==
'主借人签字'
)
and
is_bo_corporate
:
afc_contract_input
.
append
((
key
,
legal_name
))
else
:
afc_contract_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
afc_contract_input
.
append
((
key
,
field_idx
))
if
not
is_find
and
is_force
:
...
...
@@ -1535,6 +1591,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
is_cdfl_bo
=
False
# 车贷分离,主借
is_cdfl_co
=
False
# 车贷分离,共借
role_count
=
0
borrower_name
=
''
# province = cms_info.get('province', '')
for
individual_info
in
cms_info
.
get
(
'applicantInformation'
,
[]):
role_count
+=
1
...
...
@@ -1554,6 +1611,16 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
if
individual_info
[
'applicantType'
]
==
consts
.
APPLICANT_TYPE_ORDER
[
0
]
and
not
is_corporate
:
is_cdfl_bo
=
True
# CHINARPA-4660 是否公户判断
is_bo_corporate
=
False
customersubType
=
individual_info
.
get
(
'customersubType'
,
''
)
if
individual_info
[
'applicantType'
]
==
consts
.
APPLICANT_TYPE_ORDER
[
0
]
and
is_corporate
:
is_bo_corporate
=
True
# CHINARPA-4660 财报主借人姓名赋值
if
individual_info
[
'applicantType'
]
==
consts
.
APPLICANT_TYPE_ORDER
[
0
]:
borrower_name
=
customer_name
for
id_info
in
individual_info
.
get
(
'IDInformation'
,
[]):
if
id_info
.
get
(
'idType'
)
in
consts
.
SE_CMS_FIRST_ID_FIELD_MAPPING
:
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
else
:
bl_field_input
.
append
((
'establishmentDate'
,
establishment_date
))
compare_log
.
info
(
'{0} [bl_field_input] [{1}]'
.
format
(
log_base
,
bl_field_input
))
license_dict
[
consts
.
BL_EN
]
=
bl_field_input
all_id_num
.
append
(
id_num
)
...
...
@@ -1601,6 +1669,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
(
customer_name
,
'、'
.
join
(
all_id_num
),
all_id_num
[
0
])
)
compare_log
.
info
(
'{0} [license_dict] [{1}]'
.
format
(
log_base
,
license_dict
))
if
len
(
license_dict
)
>
0
:
individual_info_dict
.
setdefault
(
individual_info
[
'applicantType'
],
[])
.
append
(
license_dict
)
...
...
@@ -1721,6 +1790,39 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
vehicle_info
[
consts
.
UCI_EN
]
=
vehicle_field_input
compare_info
[
'vehicleInfo'
]
=
vehicle_info
# 公户财务报表-------------------------------------------------------------------------------------------------
financial_statement_info
=
{}
financial_statement_input
=
[]
corporateFinancialInformation
=
cms_info
.
get
(
'corporateFinancialInformation'
,
{})
hashCode
=
corporateFinancialInformation
.
get
(
'hashCode'
,
''
)
fiscalYear
=
corporateFinancialInformation
.
get
(
'fiscalYear'
,
''
)
totalAssets
=
corporateFinancialInformation
.
get
(
'totaAssets'
,
0
)
totalLiabilitiesAndOwnersEquity
=
corporateFinancialInformation
.
get
(
'totalLiabilitiesAndOwnersEquity'
,
0
)
netProfit
=
corporateFinancialInformation
.
get
(
'netProfit'
,
0
)
if
is_bo_corporate
:
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
0
],
hashCode
))
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
1
],
consts
.
SE_STAMP_VALUE
))
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
2
],
fiscalYear
))
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
3
],
[
totalAssets
,
totalLiabilitiesAndOwnersEquity
]))
financial_statement_input
.
append
((
consts
.
SE_FS_FIELD
[
4
],
[
netProfit
]))
financial_statement_info
[
consts
.
FS_EN
]
=
financial_statement_input
compare_info
[
'financialStatementInfo'
]
=
financial_statement_info
# 财报情况说明
financial_statement_supplementary_info
=
{}
financial_statement_supplementary_input
=
[]
cashAndCashEquivalentAtEndOfPeriod
=
corporateFinancialInformation
.
get
(
'cashAndCashEquivalentAtEndOfPeriod'
,
''
)
if
cashAndCashEquivalentAtEndOfPeriod
==
''
:
need_fss
=
False
else
:
need_fss
=
float
(
cashAndCashEquivalentAtEndOfPeriod
)
==
0
if
is_bo_corporate
and
need_fss
:
financial_statement_supplementary_input
.
append
((
consts
.
SE_FSS_FIELD
[
0
],
borrower_name
))
financial_statement_supplementary_input
.
append
((
consts
.
SE_FSS_FIELD
[
1
],
consts
.
SE_STAMP_VALUE
))
financial_statement_supplementary_info
[
consts
.
FSS_EN
]
=
financial_statement_supplementary_input
compare_info
[
'financialStatementSupplementaryInfo'
]
=
financial_statement_supplementary_info
# 银行卡-------------------------------------------------------------------------------------------------------
bank_info
=
{}
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
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
hil_contract_1_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
if
key
==
'承租人签字'
and
is_bo_corporate
:
hil_contract_1_input
.
append
((
key
,
legal_name
))
else
:
hil_contract_1_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
hil_contract_1_input
.
append
((
key
,
field_idx
))
if
not
is_find
and
is_force
:
...
...
@@ -1958,7 +2063,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
(
consts
.
SE_HIL_CON_3_FIELD
[
6
],
main_id
),
]
if
online_sign
:
hil_contract_3_input
.
append
((
consts
.
SE_HIL_CON_3_FIELD
[
7
],
main_name
))
if
is_bo_corporate
:
hil_contract_3_input
.
append
((
consts
.
SE_HIL_CON_3_FIELD
[
7
],
legal_name
))
else
:
hil_contract_3_input
.
append
((
consts
.
SE_HIL_CON_3_FIELD
[
7
],
main_name
))
contract_info
[
consts
.
HIL_CONTRACT_3_EN
]
=
hil_contract_3_input
# HIL合同 车辆租赁抵押合同 --------------------------------------------------------------------------------------
...
...
@@ -1981,7 +2089,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
hil_contract_2_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
if
key
==
'抵押人签字'
and
is_bo_corporate
:
hil_contract_2_input
.
append
((
key
,
legal_name
))
else
:
hil_contract_2_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
hil_contract_2_input
.
append
((
key
,
field_idx
))
if
not
is_find
and
is_force
:
...
...
@@ -2048,7 +2159,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
if
len
(
main_role_info
[
app_type
])
>=
id_idx
+
1
:
is_find
=
True
if
isinstance
(
field_idx
,
int
):
afc_contract_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
if
(
key
==
'借款人签字及时间'
or
key
==
'主借人签字'
)
and
is_bo_corporate
:
afc_contract_input
.
append
((
key
,
legal_name
))
else
:
afc_contract_input
.
append
((
key
,
main_role_info
[
app_type
][
id_idx
][
field_idx
]))
else
:
afc_contract_input
.
append
((
key
,
field_idx
))
if
not
is_find
and
is_force
:
...
...
@@ -2346,6 +2460,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
section_img_info
=
dict
()
field_img_path_dict
=
dict
()
ocr_res_str
=
ocr_res_dict
.
get
(
ocr_field
)
compare_log
.
info
(
'{0} [{1}_compare] ocr_res:{2}'
.
format
(
log_base
,
license_en
,
ocr_res_str
))
if
ocr_res_str
is
not
None
:
ocr_res_list
=
json
.
loads
(
ocr_res_str
)
...
...
@@ -2395,11 +2510,17 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
if
isinstance
(
ocr_str
,
str
):
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
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
))
no_key
=
False
# 二手车交易凭证 日期
elif
ocr_field
==
consts
.
JYPZ_OCR_FIELD
and
name
==
consts
.
SE_GB_USED_FIELD
[
2
]:
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
no_key
=
False
elif
isinstance
(
ocr_str
,
int
):
# 目前应该只有财报的公章
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
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
))
no_key
=
False
else
:
result
=
consts
.
RESULT_N
ocr_str
=
empty_str
...
...
@@ -2523,6 +2644,113 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
return
result_field_list
,
no_ocr_result
,
field_img_path_dict
def
se_fs_compare
(
license_en
,
ocr_res_dict
,
field_list
):
compare_log
.
info
(
'{0} [se_fs_compare] start'
.
format
(
log_base
))
ocr_field
,
compare_logic
,
special_expiry_date
=
consts
.
SE_COMPARE_FIELD
[
license_en
]
is_find
=
False
no_ocr_result
=
False
special_expiry_date_slice
=
False
result_field_list
=
[]
section_img_info
=
dict
()
field_img_path_dict
=
dict
()
ocr_res_str
=
ocr_res_dict
.
get
(
ocr_field
)
compare_log
.
info
(
'{0} [se_fs_compare] ocr_res:{1}'
.
format
(
log_base
,
ocr_res_str
))
if
ocr_res_str
is
not
None
:
ocr_res_list
=
json
.
loads
(
ocr_res_str
)
length
=
len
(
ocr_res_list
)
last_ocr_str
=
ocr_res_list
[
length
-
1
]
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'
,{}))))
if
len
(
last_ocr_str
.
get
(
'code'
,{}))
!=
3
or
len
(
last_ocr_str
.
get
(
'stamp'
,{}))
!=
3
:
# 先判断最后一次上传的文件是不是包括3个,如果不是直接返回"未提供财报或财报不完整"
compare_log
.
info
(
'{0} [se_fs_compare error] last ocr result len < 3'
.
format
(
log_base
))
else
:
for
res_idx
in
range
(
length
-
1
,
-
1
,
-
1
):
if
is_find
:
break
for
idx
,
(
name
,
value
)
in
enumerate
(
field_list
):
compare_log
.
info
(
'{0} [se_fs_compare for ... in] [idx:{1}] [name:{2}] [value:{3}]'
.
format
(
log_base
,
idx
,
name
,
value
))
ocr_str
=
ocr_res_list
[
res_idx
]
.
get
(
compare_logic
[
name
][
0
])
compare_log
.
info
(
'{0} [se_fs_compare ocr_str] [ocr_str:{1}]'
.
format
(
log_base
,
ocr_str
))
#财年/资产负债表内容/利润表内容 不需要ocr结果,所以即使为空也可以进入比对
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
]
==
'利润表内容'
:
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
compare_log
.
info
(
'{0} [se_fs_compare result:{1}]'
.
format
(
log_base
,
result
))
no_key
=
False
else
:
result
=
consts
.
RESULT_N
ocr_str
=
empty_str
no_key
=
True
if
idx
==
0
and
result
==
consts
.
RESULT_N
and
length
>
1
:
break
is_find
=
True
section_img_info
[
consts
.
SECTION_IMG_PATH_KEY
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
SECTION_IMG_PATH_KEY
,
''
)
section_img_info
[
consts
.
ALL_POSITION_KEY
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
ALL_POSITION_KEY
,
{})
if
special_expiry_date
:
section_img_info
[
consts
.
SECTION_IMG_PATH_KEY_2
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
SECTION_IMG_PATH_KEY_2
,
''
)
section_img_info
[
consts
.
ALL_POSITION_KEY_2
]
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
ALL_POSITION_KEY_2
,
{})
img_path
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
IMG_PATH_KEY
,
''
)
if
result
==
consts
.
RESULT_N
else
empty_str
if
isinstance
(
value
,
list
):
value
=
json
.
dumps
(
value
,
ensure_ascii
=
False
)
error_type
=
empty_error_type
if
result
==
consts
.
RESULT_Y
else
ErrorType
.
OCR
.
value
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
,
img_path
,
error_type
,
compare_logic
[
name
][
3
]))
else
:
no_ocr_result
=
True
if
not
is_find
:
for
name
,
value
in
field_list
:
if
isinstance
(
value
,
list
):
value
=
json
.
dumps
(
value
,
ensure_ascii
=
False
)
no_find_str
=
consts
.
FS_NO_FIND
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
empty_str
,
empty_str
,
ErrorType
.
NF
.
value
,
no_find_str
))
if
is_find
:
section_img_path
=
section_img_info
.
get
(
consts
.
SECTION_IMG_PATH_KEY
,
''
)
if
os
.
path
.
exists
(
section_img_path
):
failed_field
=
[]
base_img_path
=
empty_str
for
name
,
_
,
result
,
_
,
img_path
,
_
,
_
in
result_field_list
:
if
result
==
consts
.
RESULT_N
:
if
special_expiry_date_slice
and
name
==
'idExpiryDate'
:
continue
failed_field
.
append
(
name
)
if
base_img_path
==
empty_str
:
base_img_path
=
img_path
if
len
(
failed_field
)
>
0
:
info
=
section_img_info
.
get
(
consts
.
ALL_POSITION_KEY
,
{})
section_position
=
info
.
get
(
consts
.
POSITION_KEY
,
{})
section_angle
=
info
.
get
(
consts
.
ANGLE_KEY
,
0
)
try
:
last_img
=
img_process
(
section_img_path
,
section_position
,
section_angle
)
except
Exception
as
e
:
for
field
in
failed_field
:
field_img_path_dict
[
field
]
=
base_img_path
else
:
pre
,
suf
=
os
.
path
.
splitext
(
section_img_path
)
for
field
in
failed_field
:
try
:
res_field
=
compare_logic
[
field
][
0
]
is_valid
,
coord_tuple
=
field_build_coordinates
(
info
.
get
(
res_field
,
{}))
if
is_valid
:
save_path
=
'{0}_{1}{2}'
.
format
(
pre
,
field
,
suf
)
field_img
=
last_img
[
coord_tuple
[
0
]:
coord_tuple
[
1
],
coord_tuple
[
2
]:
coord_tuple
[
3
],
:]
cv2
.
imwrite
(
save_path
,
field_img
)
field_img_path_dict
[
field
]
=
save_path
else
:
field_img_path_dict
[
field
]
=
base_img_path
except
Exception
as
e
:
field_img_path_dict
[
field
]
=
base_img_path
return
result_field_list
,
field_img_path_dict
def
se_compare_license_id
(
license_en
,
id_res_list
,
field_list
,
is_auto
):
if
is_auto
:
...
...
@@ -3023,9 +3251,11 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
rpa_failure_reason
=
{}
field_result_dict
=
{}
# compare_info 格式: {'financialStatementInfo': {'Financial Statement': [('11', '22'), ('111', '222'), ('1111', '2222')]}}
for
info_key
,
info_value
in
compare_info
.
items
():
if
info_key
in
[
'individualCusInfo'
,
'applicantInformation'
]:
for
idx
,
license_list
in
info_value
.
items
():
compare_log
.
info
(
'{0} [compare license_list] [entity={1}]'
.
format
(
log_base
,
license_list
))
for
license_dict
in
license_list
:
for
license_en
,
field_list
in
license_dict
.
items
():
strip_list
=
[]
...
...
@@ -3081,6 +3311,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
each_license_failed_count
,
len
(
result_field_list
)))
else
:
for
license_en
,
field_list
in
info_value
.
items
():
compare_log
.
info
(
'{0} [compare license_en] [entity={1}]'
.
format
(
log_base
,
license_en
))
strip_list
=
[]
for
a
,
b
in
field_list
:
if
isinstance
(
b
,
str
):
...
...
@@ -3104,6 +3335,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
result_field_list
,
field_img_path_dict
=
se_contract_qrs_compare
(
license_en
,
ocr_res_dict
,
strip_list
)
elif
license_en
==
consts
.
BS_EN
:
result_field_list
,
field_img_path_dict
=
se_bs_compare
(
license_en
,
ocr_res_dict
,
strip_list
,
is_auto
,
aa_type
)
elif
license_en
==
consts
.
FS_EN
:
result_field_list
,
field_img_path_dict
=
se_fs_compare
(
license_en
,
ocr_res_dict
,
strip_list
)
else
:
result_field_list
,
_
,
field_img_path_dict
=
se_compare_license
(
license_en
,
ocr_res_dict
,
strip_list
)
...
...
src/common/tools/comparison.py
View file @
a0d6443
...
...
@@ -704,5 +704,58 @@ class Comparison:
except
Exception
as
e
:
return
self
.
RESULT_N
def
hash_code_compare
(
self
,
input_str
,
ocr_dict
,
**
kwargs
):
try
:
balance_sheet_hash
=
ocr_dict
.
get
(
'balance_sheet'
,
''
)
income_statement_hash
=
ocr_dict
.
get
(
'income_statement'
,
''
)
cash_flow_statement_hash
=
ocr_dict
.
get
(
'cash_flow_statement'
,
''
)
if
balance_sheet_hash
!=
input_str
or
income_statement_hash
!=
input_str
or
cash_flow_statement_hash
!=
input_str
:
return
self
.
RESULT_N
else
:
return
self
.
RESULT_Y
except
Exception
as
e
:
return
self
.
RESULT_N
def
stamp_dict_compare
(
self
,
input_str
,
ocr_dict
,
**
kwargs
):
try
:
balance_sheet_stamp
=
ocr_dict
.
get
(
'balance_sheet'
,
''
)
income_statement_stamp
=
ocr_dict
.
get
(
'income_statement'
,
''
)
cash_flow_statement_stamp
=
ocr_dict
.
get
(
'cash_flow_statement'
,
''
)
if
balance_sheet_stamp
!=
1
or
income_statement_stamp
!=
1
or
cash_flow_statement_stamp
!=
1
:
return
self
.
RESULT_N
else
:
return
self
.
RESULT_Y
except
Exception
as
e
:
return
self
.
RESULT_N
def
stamp_str_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
try
:
if
ocr_str
!=
1
:
return
self
.
RESULT_N
else
:
return
self
.
RESULT_Y
except
Exception
as
e
:
return
self
.
RESULT_N
def
fiscal_year_compare
(
self
,
input_str
,
ocr_list
,
**
kwargs
):
try
:
this_year_str
=
datetime
.
now
()
.
strftime
(
'
%
Y'
)
this_year
=
int
(
this_year_str
)
last_year
=
this_year
-
1
if
str
(
input_str
)
!=
str
(
this_year
)
and
str
(
input_str
)
!=
str
(
last_year
):
return
self
.
RESULT_N
return
self
.
RESULT_Y
except
Exception
as
e
:
return
self
.
RESULT_N
def
input_list_not_zero_compare
(
self
,
input_list
,
ocr_list
,
**
kwargs
):
try
:
for
item
in
input_list
:
if
float
(
item
)
==
0
:
return
self
.
RESULT_N
return
self
.
RESULT_Y
except
Exception
as
e
:
return
self
.
RESULT_N
cp
=
Comparison
()
...
...
src/common/tools/mssql_script28.py
0 → 100644
View file @
a0d6443
import
pyodbc
hil_sql
=
"""
ALTER TABLE hil_ocr_result ADD fs_ocr nvarchar(max);
ALTER TABLE hil_se_ocr_result ADD fs_ocr nvarchar(max);
ALTER TABLE hil_ocr_result ADD fss_ocr nvarchar(max);
ALTER TABLE hil_se_ocr_result ADD fss_ocr nvarchar(max);
"""
afc_sql
=
"""
ALTER TABLE afc_ocr_result ADD fs_ocr nvarchar(max);
ALTER TABLE afc_se_ocr_result ADD fs_ocr nvarchar(max);
ALTER TABLE afc_ocr_result ADD fss_ocr nvarchar(max);
ALTER TABLE afc_se_ocr_result ADD fss_ocr nvarchar(max);
"""
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
hil_cursor
=
hil_cnxn
.
cursor
()
hil_cursor
.
execute
(
hil_sql
)
hil_cursor
.
close
()
hil_cnxn
.
close
()
afc_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
afc_cursor
=
afc_cnxn
.
cursor
()
afc_cursor
.
execute
(
afc_sql
)
afc_cursor
.
close
()
afc_cnxn
.
close
()
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment