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
de9a84b7
authored
2021-12-16 15:44:22 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
a619e9ec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
30 deletions
src/apps/doc/consts.py
src/apps/doc/ocr/wb.py
src/celery_compare/tasks.py
src/apps/doc/consts.py
View file @
de9a84b
...
...
@@ -1109,6 +1109,7 @@ OTHER_CLASSIFY_SET = {OTHER_CLASSIFY}
LICENSE_CLASSIFY_SET_1
=
{
IC_CLASSIFY
,
VAT_CLASSIFY
,
MVC_CLASSIFY
,
MVI_CLASSIFY
,
UCI_CLASSIFY
,
DDA_CLASSIFY
,
HMH_CLASSIFY
,
JYPZ_CLASSIFY
,
INSURANCE_CLASSIFY
}
LICENSE_CLASSIFY_SET_2
=
{
BL_CLASSIFY
,
EEP_CLASSIFY
,
DL_CLASSIFY
,
PP_CLASSIFY
,
BC_CLASSIFY
}
BS_VERIFY_CLASSIFY
=
{
11
,
17
}
NYYH_CLASSIFY
=
{
17
,
18
}
NYZS_CLASSIFY
=
18
SPECIAL_NYZS_CLASSIFY
=
50
...
...
@@ -1517,7 +1518,7 @@ SE_HIL_CON_3_MAP = {
'销售经销商'
:
(
1
,
None
,
5
,
'销售经销商'
,
None
),
'合同编号-正文'
:
(
1
,
None
,
5
,
'合同编号(正文)'
,
None
),
'姓名/名称'
:
(
4
,
None
,
5
,
'签字页-承租人姓名'
,
None
),
'自然人身份证件号码/法人执照号码'
:
(
4
,
None
,
5
,
'签字页-
自然人身份证件号码/法人执照
号码'
,
None
),
'自然人身份证件号码/法人执照号码'
:
(
4
,
None
,
5
,
'签字页-
承租人证件
号码'
,
None
),
'承租人签字'
:
(
4
,
None
,
5
,
'签字页-承租人签章'
,
None
),
}
...
...
@@ -1788,6 +1789,19 @@ BS_COMPARE_LOGIC = {
SPECIAL_REASON
=
'主共借人未提供银行流水,含担保人需人工查看直系亲属关系'
SPECIAL_REASON_2
=
'担保人未提供银行流水,需人工查看直系亲属关系'
SPECIAL_REASON_3
=
'未提供银行流水'
BS_REASON
=
{
'主共借人未提供银行流水,含担保人需人工查看直系亲属关系'
,
'担保人未提供银行流水,需人工查看直系亲属关系'
,
'未提供银行流水'
,
'主共借人未提供银行流水'
,
'担保人未提供银行流水'
,
'主共借人银行流水打印日期超过15天'
,
'担保人银行流水打印日期超过15天'
,
'主共借人银行流水日期不满足3个月'
,
'担保人银行流水日期不满足3个月'
}
# ['合同编号-每页', '合同编号-正文', '车辆识别代码', '车辆卖方', '车辆原始销售价格', '融资成本总额', '租期', '还款计划表', 'ASP项目详情', '购置税校验', '承租人法定代表人或授权代表']
# ['承租人姓名', '承租人证件号', '承租人签字', '共同承租人姓名', '共同承租人证件号', '共同承租人签字', '保证人姓名1', '保证人证件号1', '保证人签字1', '保证人姓名2', '保证人证件号2', '保证人签字2']
...
...
@@ -1799,7 +1813,7 @@ HIL_CONTRACT_1_COMPARE_LOGIC = {
'车辆原始销售价格'
:
(
'车辆原始销售价格'
,
'se_amount_str_compare'
,
{},
'售后回租合同车辆原始销售价格与系统车辆价格不一致'
),
'融资成本总额'
:
(
'融资成本总额'
,
'se_amount_str_compare'
,
{},
'售后回租合同ASP融资成本总额与系统不一致'
),
'租期'
:
(
'租期'
,
'se_contain_compare'
,
{},
'售后回租合同首页中贷款期限系统不一致'
),
'还款计划表'
:
(
'还款计划表'
,
'se_schedule_compare'
,
{
"value_idx"
:
3
},
'售后回租合同还款计划表与系统不一致'
),
'还款计划表'
:
(
'还款计划表'
,
'se_schedule_compare'
,
{
"value_idx"
:
1
},
'售后回租合同还款计划表与系统不一致'
),
'ASP项目详情'
:
(
'ASP项目详情'
,
'se_asp_compare'
,
{},
'售后回租合同ASP名称或者金额与系统不一致'
),
'承租人法定代表人或授权代表'
:
(
'承租人法定代表人或授权代表'
,
'se_name_compare'
,
{},
'售后回租合同承租人法定代表人或授权代表与系统不一致'
),
...
...
src/apps/doc/ocr/wb.py
View file @
de9a84b
...
...
@@ -311,29 +311,32 @@ class BSWorkbook(Workbook):
month_mapping
.
setdefault
(
item
,
[])
.
append
(
(
ws
.
title
,
idx_list
[
i
]
+
min_row
,
idx_list
[
i
+
1
]
+
min_row
-
1
,
day_mean
))
def
build_metadata_rows
(
self
,
confidence
,
code
,
verify_list
,
print_time
,
start_date
,
end_date
,
res_count_tuple
):
if
start_date
is
None
or
end_date
is
None
:
timedelta
=
None
else
:
timedelta
=
(
end_date
-
start_date
)
.
days
verify_res
=
'正常'
if
len
(
verify_list
)
>
0
:
verify_res
=
'疑似伪造'
def
build_metadata_rows
(
self
,
confidence
,
code
,
verify_list
,
print_time
,
start_date
,
end_date
,
res_count_tuple
,
is_verify_classify
):
metadata_rows
=
[
(
'流水识别置信度'
,
confidence
),
(
'流水检测结果'
,
verify_res
),
(
'图片总数'
,
res_count_tuple
[
0
]),
(
'识别成功'
,
res_count_tuple
[
1
]),
self
.
blank_row
,
self
.
code_header
,
]
metadata_rows
.
extend
(
code
)
if
len
(
verify_list
)
>
0
:
metadata_rows
.
append
(
self
.
blank_row
)
metadata_rows
.
append
(
self
.
verify_header
)
metadata_rows
.
extend
(
verify_list
)
verify_highlight_row
=
[]
if
is_verify_classify
:
verify_res
=
'疑似伪造'
if
len
(
verify_list
)
>
0
else
'正常'
metadata_rows
.
append
((
'流水检测结果'
,
verify_res
))
if
len
(
verify_list
)
>
0
:
metadata_rows
.
append
(
self
.
verify_header
)
metadata_rows
.
extend
(
verify_list
)
for
r
in
range
(
5
,
len
(
metadata_rows
)
+
1
):
verify_highlight_row
.
append
(
r
)
metadata_rows
.
append
(
self
.
blank_row
)
metadata_rows
.
append
(
self
.
code_header
)
metadata_rows
.
extend
(
code
)
if
start_date
is
None
or
end_date
is
None
:
timedelta
=
None
else
:
timedelta
=
(
end_date
-
start_date
)
.
days
metadata_rows
.
extend
(
[
self
.
blank_row
,
self
.
date_header
,
...
...
@@ -341,22 +344,24 @@ class BSWorkbook(Workbook):
self
.
blank_row
,
self
.
interest_keyword_header
]
)
return
metadata_rows
return
metadata_rows
,
verify_highlight_row
def
build_meta_sheet
(
self
,
role_name
,
card
,
confidence
,
code
,
verify_list
,
print_time
,
start_date
,
end_date
,
res_count_tuple
):
metadata_rows
=
self
.
build_metadata_rows
(
confidence
,
code
,
verify_list
,
print_time
,
start_date
,
end_date
,
res_count_tuple
)
def
build_meta_sheet
(
self
,
role_name
,
card
,
confidence
,
code
,
verify_list
,
print_time
,
start_date
,
end_date
,
res_count_tuple
,
is_verify_classify
):
metadata_rows
,
verify_highlight_row
=
self
.
build_metadata_rows
(
confidence
,
code
,
verify_list
,
print_time
,
start_date
,
end_date
,
res_count_tuple
,
is_verify_classify
)
if
not
isinstance
(
role_name
,
str
):
role_name
=
consts
.
UNKNOWN_ROLE
ms
=
self
.
create_sheet
(
'{0}{1}({2})'
.
format
(
self
.
meta_sheet_title
,
role_name
,
card
))
for
row
in
metadata_rows
:
ms
.
append
(
row
)
if
len
(
verify_list
)
>
0
:
for
cell
in
ms
[
2
]:
for
row
in
verify_highlight_row
:
for
cell
in
ms
[
row
]:
cell
.
fill
=
self
.
amount_fill
if
res_count_tuple
[
0
]
!=
res_count_tuple
[
1
]:
for
cell
in
ms
[
3
]:
for
cell
in
ms
[
2
]:
cell
.
fill
=
self
.
amount_fill
for
cell
in
ms
[
4
]:
for
cell
in
ms
[
3
]:
cell
.
fill
=
self
.
amount_fill
return
ms
...
...
@@ -672,6 +677,7 @@ class BSWorkbook(Workbook):
# 2.元信息提取表
confidence
=
self
.
get_confidence
(
max_find_count
)
is_verify_classify
=
classify
in
consts
.
BS_VERIFY_CLASSIFY
ms
=
self
.
build_meta_sheet
(
role_name
,
new_card
,
confidence
,
...
...
@@ -680,7 +686,8 @@ class BSWorkbook(Workbook):
summary
.
get
(
'print_time'
),
start_date
,
end_date
,
res_count_tuple
)
res_count_tuple
,
is_verify_classify
)
# 3.创建月份表、提取/高亮关键行
# 倒序处理
...
...
src/celery_compare/tasks.py
View file @
de9a84b
...
...
@@ -1628,7 +1628,7 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list):
if
isinstance
(
value
,
list
):
value
=
json
.
dumps
(
value
,
ensure_ascii
=
False
)
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
empty_str
,
empty_str
,
ErrorType
.
NF
.
value
,
'未提供银行流水'
))
consts
.
SPECIAL_REASON_3
))
return
result_field_list
,
field_img_path_dict
...
...
@@ -2062,6 +2062,7 @@ def se_compare_process(compare_info, ocr_res_dict):
result_field_list
,
field_img_path_dict
=
se_bs_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
)
for
name
,
value
,
result
,
ocr_str
,
img_path
,
error_type
,
cn_reason
in
result_field_list
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
...
...
@@ -2091,6 +2092,7 @@ def se_compare_process(compare_info, ocr_res_dict):
if
failed_count
==
0
:
failure_reason_str
=
''
cn_failure_reason_str
=
''
bs_failure_reason_str
=
''
else
:
reason_list
=
[]
for
key
,
value
in
failure_reason
.
items
():
...
...
@@ -2098,16 +2100,22 @@ def se_compare_process(compare_info, ocr_res_dict):
value_str
=
json
.
dumps
(
value
)
reason_list
.
append
(
'{0}: {1}'
.
format
(
key
,
value_str
))
failure_reason_str
=
'、'
.
join
(
reason_list
)
tmp_set
=
set
()
last_cn_reason_list
=
[]
bs_cn_reason_list
=
[]
for
i
in
cn_reason_list
:
if
i
in
tmp_set
:
continue
elif
i
in
consts
.
BS_REASON
:
tmp_set
.
add
(
i
)
bs_cn_reason_list
.
append
(
i
)
else
:
tmp_set
.
add
(
i
)
last_cn_reason_list
.
append
(
i
)
cn_failure_reason_str
=
'
\n
'
.
join
(
last_cn_reason_list
)
return
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
cn_failure_reason_str
bs_failure_reason_str
=
'
\n
'
.
join
(
bs_cn_reason_list
)
return
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
cn_failure_reason_str
,
bs_failure_reason_str
def
se_result_detect
(
ocr_res_dict
):
...
...
@@ -2131,8 +2139,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
else
:
compare_info
=
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
=
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
)
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
:
...
...
@@ -2198,7 +2205,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
"Result_Message"
:
"Pass"
if
successful_at_this_level
else
"Fail"
,
"Failure_Reason"
:
cn_failure_reason_str
,
"Application_Number"
:
application_id
,
"Bank_Statement"
:
""
,
"Bank_Statement"
:
bs_failure_reason_str
,
"Link_URL"
:
application_link
,
"OCR_Version"
:
1
,
"Origin"
:
consts
.
INFO_SOURCE
[
1
]
...
...
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