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
b2cb841e
authored
2021-12-16 20:01:56 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix afc contract bank
1 parent
79e91f0b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
21 deletions
src/apps/doc/consts.py
src/celery_compare/tasks.py
src/common/tools/comparison.py
src/apps/doc/consts.py
View file @
b2cb841
...
...
@@ -1484,17 +1484,17 @@ SE_HIL_CON_1_MAP = {
'承租人证件号'
:
(
1
,
1
,
7
,
'承租人-证件号码'
,
None
),
'承租人签字'
:
(
6
,
6
,
7
,
'签字页-承租人姓名'
,
None
),
'共同承租人姓名'
:
(
1
,
1
,
7
,
'
共同承租人
-姓名'
,
None
),
'共同承租人证件号'
:
(
1
,
1
,
7
,
'
共同承租人
-证件号码'
,
None
),
'共同承租人签字'
:
(
6
,
6
,
7
,
'签字页-
共同承租人
姓名'
,
None
),
'共同承租人姓名'
:
(
1
,
1
,
7
,
'
保证人1
-姓名'
,
None
),
'共同承租人证件号'
:
(
1
,
1
,
7
,
'
保证人1
-证件号码'
,
None
),
'共同承租人签字'
:
(
6
,
6
,
7
,
'签字页-
保证人1
姓名'
,
None
),
'保证人姓名1'
:
(
1
,
1
,
7
,
'保证人
1
-姓名'
,
None
),
'保证人证件号1'
:
(
1
,
1
,
7
,
'保证人
1
-证件号码'
,
None
),
'保证人签字1'
:
(
6
,
6
,
7
,
'签字页-保证人
1
姓名'
,
None
),
'保证人姓名1'
:
(
1
,
1
,
7
,
'保证人
2
-姓名'
,
None
),
'保证人证件号1'
:
(
1
,
1
,
7
,
'保证人
2
-证件号码'
,
None
),
'保证人签字1'
:
(
6
,
6
,
7
,
'签字页-保证人
2
姓名'
,
None
),
'保证人姓名2'
:
(
1
,
1
,
7
,
'保证人
2
-姓名'
,
None
),
'保证人证件号2'
:
(
1
,
1
,
7
,
'保证人
2
-证件号码'
,
None
),
'保证人签字2'
:
(
6
,
6
,
7
,
'签字页-保证人
2
姓名'
,
None
),
'保证人姓名2'
:
(
1
,
1
,
7
,
'保证人
3
-姓名'
,
None
),
'保证人证件号2'
:
(
1
,
1
,
7
,
'保证人
3
-证件号码'
,
None
),
'保证人签字2'
:
(
6
,
6
,
7
,
'签字页-保证人
3
姓名'
,
None
),
}
SE_HIL_CON_2_MAP
=
{
...
...
@@ -1532,6 +1532,7 @@ SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条
'车辆贷款本金金额-重要条款'
,
'附加产品融资贷款本金总额-重要条款'
,
'所购车辆价格'
,
'车架号'
,
'经销商'
,
'贷款本金金额'
,
'车辆贷款本金金额'
,
'附加产品融资贷款本金总额'
,
'贷款期限'
,
'还款账号'
,
'户名'
,
'开户行'
,
'还款计划表'
,
'见证人签字'
,
'见证人日期'
,
'ASP项目详情-重要条款'
,
'购置税校验'
,
'ASP项目详情'
]
AFC_CON_BANK_FIELD
=
[
'还款账号'
,
'户名'
,
'开户行'
]
# '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表'
SE_HIL_CON_1_FIELD
=
[
'合同编号-每页'
,
'合同编号-正文'
,
'车辆识别代码'
,
'车辆卖方'
,
'车辆原始销售价格'
,
'融资成本总额'
,
'租期'
,
...
...
src/celery_compare/tasks.py
View file @
b2cb841
...
...
@@ -1275,7 +1275,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
hil_contract_2_input
.
append
((
key
,
empty_str
))
contract_info
[
consts
.
HIL_CONTRACT_2_EN
]
=
hil_contract_2_input
compare_info
[
'contract'
]
=
contract_info
return
compare_info
,
cms_info
.
get
(
'applicationVersion'
,
1
)
return
compare_info
,
cms_info
.
get
(
'applicationVersion'
,
1
)
,
is_gsyh
else
:
# AFC合同-----------------------------------------------------------------------------------------------------------
vehicle_principal_str
=
str
(
cms_info
.
get
(
'financialInformation'
,
{})
.
get
(
'vehiclePrincipal'
,
'0.0'
))
...
...
@@ -1331,7 +1331,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
contract_info
[
consts
.
AFC_CONTRACT_EN
]
=
afc_contract_input
compare_info
[
'contract'
]
=
contract_info
return
compare_info
,
cms_info
.
get
(
'applicationVersion'
,
1
)
return
compare_info
,
cms_info
.
get
(
'applicationVersion'
,
1
)
,
is_gsyh
def
get_se_compare_info
(
last_obj
,
application_entity
,
detect_list
):
...
...
@@ -1507,7 +1507,7 @@ def get_se_compare_info(last_obj, application_entity, detect_list):
other_info
[
consts
.
HMH_EN
]
=
hmh_field_input
compare_info
[
'other'
]
=
other_info
return
compare_info
return
compare_info
,
is_gsyh
def
se_bs_compare
(
license_en
,
ocr_res_dict
,
strip_list
):
...
...
@@ -1801,7 +1801,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
return
result_field_list
,
no_ocr_result
,
field_img_path_dict
def
se_contract_compare
(
license_en
,
ocr_res_dict
,
strip_list
):
def
se_contract_compare
(
license_en
,
ocr_res_dict
,
strip_list
,
is_gsyh
):
ocr_field
,
compare_logic
,
_
=
consts
.
SE_COMPARE_FIELD
[
license_en
]
ocr_res_str
=
ocr_res_dict
.
get
(
ocr_field
)
...
...
@@ -1834,8 +1834,19 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list):
ocr_str
=
empty_str
else
:
ocr_str_or_list
=
ocr_res
.
get
(
compare_logic
[
name
][
0
])
if
isinstance
(
ocr_str_or_list
,
str
)
or
isinstance
(
ocr_str_or_list
,
list
):
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str_or_list
,
**
compare_logic
[
name
][
2
])
if
ocr_str_or_list
is
None
and
license_en
==
consts
.
AFC_CONTRACT_EN
\
and
is_gsyh
is
True
and
name
in
consts
.
AFC_CON_BANK_FIELD
:
result
=
consts
.
RESULT_Y
ocr_str
=
empty_str
reason
=
compare_logic
[
name
][
3
]
elif
isinstance
(
ocr_str_or_list
,
str
)
or
isinstance
(
ocr_str_or_list
,
list
):
if
license_en
==
consts
.
AFC_CONTRACT_EN
and
is_gsyh
is
True
and
name
in
consts
.
AFC_CON_BANK_FIELD
:
update_args
=
{
'is_gsyh'
:
is_gsyh
}
for
k
,
v
in
compare_logic
[
name
][
2
]
.
items
():
update_args
[
k
]
=
v
else
:
update_args
=
compare_logic
[
name
][
2
]
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str_or_list
,
**
update_args
)
if
isinstance
(
ocr_str_or_list
,
list
):
ocr_str
=
json
.
dumps
(
ocr_str_or_list
,
ensure_ascii
=
False
)
else
:
...
...
@@ -1847,7 +1858,10 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list):
reason
=
compare_logic
[
name
][
3
]
# img_path = empty_str
img_path
=
ocr_res
.
get
(
consts
.
IMG_PATH_KEY
,
{})
.
get
(
compare_logic
[
name
][
0
],
empty_str
)
if
result
==
consts
.
RESULT_N
else
empty_str
if
name
not
in
compare_logic
:
img_path
=
empty_str
else
:
img_path
=
ocr_res
.
get
(
consts
.
IMG_PATH_KEY
,
{})
.
get
(
compare_logic
[
name
][
0
],
empty_str
)
if
result
==
consts
.
RESULT_N
else
empty_str
error_type
=
empty_error_type
if
result
==
consts
.
RESULT_Y
else
ErrorType
.
OCR
.
value
if
isinstance
(
value
,
list
):
value
=
json
.
dumps
(
value
,
ensure_ascii
=
False
)
...
...
@@ -1980,7 +1994,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
return
result_field_list
,
field_img_path_dict
def
se_compare_process
(
compare_info
,
ocr_res_dict
):
def
se_compare_process
(
compare_info
,
ocr_res_dict
,
is_gsyh
):
# individualCusInfo
# corporateCusInfo
# vehicleInfo
...
...
@@ -2057,7 +2071,7 @@ def se_compare_process(compare_info, ocr_res_dict):
if
license_en
==
consts
.
MVC34_EN
:
result_field_list
,
field_img_path_dict
=
se_mvc34_compare
(
license_en
,
ocr_res_dict
,
strip_list
)
elif
license_en
in
[
consts
.
HIL_CONTRACT_1_EN
,
consts
.
HIL_CONTRACT_2_EN
,
consts
.
HIL_CONTRACT_3_EN
,
consts
.
AFC_CONTRACT_EN
]:
result_field_list
,
field_img_path_dict
=
se_contract_compare
(
license_en
,
ocr_res_dict
,
strip_list
)
result_field_list
,
field_img_path_dict
=
se_contract_compare
(
license_en
,
ocr_res_dict
,
strip_list
,
is_gsyh
)
elif
license_en
==
consts
.
BS_EN
:
result_field_list
,
field_img_path_dict
=
se_bs_compare
(
license_en
,
ocr_res_dict
,
strip_list
)
else
:
...
...
@@ -2135,11 +2149,12 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
# if is_cms:
# last_obj = rebuild_compare_info(last_obj, application_id)
if
is_cms
:
compare_info
,
application_version
=
get_se_cms_compare_info
(
last_obj
,
application_entity
,
detect_list
)
compare_info
,
application_version
,
is_gsyh
=
get_se_cms_compare_info
(
last_obj
,
application_entity
,
detect_list
)
else
:
compare_info
=
get_se_compare_info
(
last_obj
,
application_entity
,
detect_list
)
compare_info
,
is_gsyh
=
get_se_compare_info
(
last_obj
,
application_entity
,
detect_list
)
application_version
=
last_obj
.
application_version
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
cn_failure_reason_str
,
bs_failure_reason_str
=
se_compare_process
(
compare_info
,
ocr_res_dict
)
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
cn_failure_reason_str
,
bs_failure_reason_str
=
se_compare_process
(
compare_info
,
ocr_res_dict
,
is_gsyh
)
compare_log
.
info
(
'{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
compare_result
))
except
Exception
as
e
:
...
...
src/common/tools/comparison.py
View file @
b2cb841
...
...
@@ -258,6 +258,9 @@ class Comparison:
return
self
.
build_res
(
input_s
==
ocr_s
)
def
se_common_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
if
kwargs
.
get
(
'is_gsyh'
,
False
):
if
ocr_str
==
''
or
ocr_str
is
None
:
return
self
.
RESULT_Y
if
kwargs
.
get
(
'remove_space'
,
False
):
input_str
=
input_str
.
replace
(
' '
,
''
)
return
self
.
build_res
(
input_str
==
ocr_str
)
...
...
@@ -354,6 +357,9 @@ class Comparison:
return
self
.
RESULT_Y
def
se_both_contain_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
if
kwargs
.
get
(
'is_gsyh'
,
False
):
if
ocr_str
==
''
or
ocr_str
is
None
:
return
self
.
RESULT_Y
if
ocr_str
.
find
(
input_str
)
==
-
1
and
input_str
.
find
(
ocr_str
)
==
-
1
:
return
self
.
RESULT_N
else
:
...
...
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