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
1c2ccd20
authored
2022-10-19 19:14:53 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add compare report se
1 parent
924771cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
3 deletions
src/apps/doc/models.py
src/celery_compare/tasks.py
src/apps/doc/models.py
View file @
1c2ccd2
...
...
@@ -997,3 +997,41 @@ class InterfaceReport(models.Model):
class
Meta
:
managed
=
False
db_table
=
'interface_report'
class
HILCompareReportNew
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
is_se
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否Settlement"
)
is_auto
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"是否Settlement Auto"
)
is_pass
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"是否全对"
)
full_result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"完整比对结果"
)
field_result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"各证件字段统计"
)
start_time
=
models
.
DateTimeField
(
verbose_name
=
'开始时间'
)
# 索引
end_time
=
models
.
DateTimeField
(
verbose_name
=
'结束时间'
)
class
Meta
:
managed
=
False
db_table
=
'hil_compare_report_new'
class
AFCCompareReportNew
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
is_se
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否Settlement"
)
is_auto
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"是否Settlement Auto"
)
is_pass
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"是否全对"
)
full_result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"完整比对结果"
)
field_result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"各证件字段统计"
)
start_time
=
models
.
DateTimeField
(
verbose_name
=
'开始时间'
)
# 索引
end_time
=
models
.
DateTimeField
(
verbose_name
=
'结束时间'
)
class
Meta
:
managed
=
False
db_table
=
'afc_compare_report_new'
...
...
src/celery_compare/tasks.py
View file @
1c2ccd2
...
...
@@ -32,6 +32,8 @@ from apps.doc.models import (
HILbankVerification
,
AFCbankVerification
,
InterfaceReport
,
HILCompareReportNew
,
AFCCompareReportNew
,
)
from
apps.doc
import
consts
from
apps.doc.ocr.gcap
import
gcap
...
...
@@ -2843,6 +2845,7 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
failure_reason
=
{}
cn_reason_list
=
[]
rpa_failure_reason
=
{}
field_result_dict
=
{}
for
info_key
,
info_value
in
compare_info
.
items
():
if
info_key
in
[
'individualCusInfo'
,
'applicantInformation'
]:
...
...
@@ -2871,11 +2874,13 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
else
:
result_field_list
,
no_ocr_result
,
field_img_path_dict
=
se_compare_license
(
license_en
,
ocr_res_dict
,
strip_list
)
each_license_failed_count
=
0
for
name
,
value
,
result
,
ocr_str
,
img_path
,
error_type
,
cn_reason
in
result_field_list
:
if
license_en
not
in
consts
.
SKIP_CARD
or
not
no_ocr_result
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
failed_count
+=
1
each_license_failed_count
+=
1
successful_at_this_level
=
False
failure_field
.
append
(
name
)
cn_reason_list
.
append
(
cn_reason
)
...
...
@@ -2896,6 +2901,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
)
if
len
(
failure_field
)
>
0
:
failure_reason
.
setdefault
(
info_key
,
[])
.
append
(
';'
.
join
(
failure_field
))
field_result_dict
.
setdefault
(
license_en
,
[])
.
append
(
'{0}/{1}'
.
format
(
each_license_failed_count
,
len
(
result_field_list
)))
else
:
for
license_en
,
field_list
in
info_value
.
items
():
strip_list
=
[]
...
...
@@ -2922,12 +2929,14 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
else
:
result_field_list
,
_
,
field_img_path_dict
=
se_compare_license
(
license_en
,
ocr_res_dict
,
strip_list
)
each_license_failed_count
=
0
for
name
,
value
,
result
,
ocr_str
,
img_path
,
error_type
,
cn_reason
in
result_field_list
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
# if license_en != consts.MVI_EN or name != consts.SE_NEW_ADD_FIELD[9]:
successful_at_this_level
=
False
failed_count
+=
1
each_license_failed_count
+=
1
failure_field
.
append
(
name
)
if
isinstance
(
cn_reason
,
str
):
cn_reason_list
.
append
(
cn_reason
)
...
...
@@ -2951,6 +2960,9 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
)
if
len
(
failure_field
)
>
0
:
failure_reason
.
setdefault
(
info_key
,
[])
.
append
(
';'
.
join
(
failure_field
))
field_result_dict
.
setdefault
(
license_en
,
[])
.
append
(
'{0}/{1}'
.
format
(
each_license_failed_count
,
len
(
result_field_list
)))
if
failed_count
==
0
:
failure_reason_str
=
''
cn_failure_reason_str
=
''
...
...
@@ -2977,7 +2989,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
last_cn_reason_list
.
append
(
i
)
cn_failure_reason_str
=
'
\n
'
.
join
(
last_cn_reason_list
)
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
,
rpa_failure_reason
return
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
\
cn_failure_reason_str
,
bs_failure_reason_str
,
rpa_failure_reason
,
field_result_dict
def
se_result_detect
(
ocr_res_dict
):
...
...
@@ -2990,13 +3003,14 @@ def se_result_detect(ocr_res_dict):
def
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
,
ignore_bank
,
id_res_list
):
start_time
=
datetime
.
now
()
try
:
# 比对逻辑
# detect_list = se_result_detect(ocr_res_dict)
compare_info
,
aa_type
,
is_gsyh
=
get_se_cms_compare_info_auto
(
last_obj
,
application_entity
,
ignore_bank
=
ignore_bank
)
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
\
cn_failure_reason_str
,
bs_failure_reason_str
,
_
=
se_compare_process
(
cn_failure_reason_str
,
bs_failure_reason_str
,
_
,
field_result_dict
=
se_compare_process
(
compare_info
,
ocr_res_dict
,
is_gsyh
,
True
,
id_res_list
)
compare_log
.
info
(
'{0} [Auto 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
))
...
...
@@ -3032,6 +3046,25 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc
# '[error={4}]'.format(log_base, application_entity, application_id, ocr_res_id,
# traceback.format_exc()))
# 新的Report表
try
:
end_time
=
datetime
.
now
()
new_report_tabel
=
HILCompareReportNew
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCCompareReportNew
new_report_tabel
.
objects
.
create
(
application_id
=
application_id
,
is_se
=
True
,
is_auto
=
True
,
is_pass
=
successful_at_this_level
,
full_result
=
json
.
dumps
(
compare_result
),
field_result
=
json
.
dumps
(
field_result_dict
),
start_time
=
start_time
,
end_time
=
end_time
,
)
except
Exception
as
e
:
compare_log
.
error
(
'{0} [Auto SE] [db save error] [entity={1}] [id={2}] [ocr_res_id={3}] '
'[error={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
traceback
.
format_exc
()))
return
successful_at_this_level
...
...
@@ -3044,7 +3077,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
compare_info
,
application_version
,
is_gsyh
=
get_se_cms_compare_info
(
last_obj
,
application_entity
,
detect_list
,
ignore_bank
=
ignore_bank
)
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
,
\
cn_failure_reason_str
,
bs_failure_reason_str
,
rpa_failure_reason
=
se_compare_process
(
cn_failure_reason_str
,
bs_failure_reason_str
,
rpa_failure_reason
,
field_result_dict
=
se_compare_process
(
compare_info
,
ocr_res_dict
,
is_gsyh
,
False
,
id_res_list
)
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
))
...
...
@@ -3102,6 +3135,24 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
'[error={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
traceback
.
format_exc
()))
# 新的Report表
try
:
new_report_tabel
=
HILCompareReportNew
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCCompareReportNew
new_report_tabel
.
objects
.
create
(
application_id
=
application_id
,
is_se
=
True
,
is_auto
=
False
,
is_pass
=
successful_at_this_level
,
full_result
=
json
.
dumps
(
compare_result
),
field_result
=
json
.
dumps
(
field_result_dict
),
start_time
=
start_time
,
end_time
=
end_time
,
)
except
Exception
as
e
:
compare_log
.
error
(
'{0} [SE] [db save error] [entity={1}] [id={2}] [ocr_res_id={3}] '
'[error={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
traceback
.
format_exc
()))
# cms结果发送
is_cms_send
=
Configs
.
objects
.
filter
(
id
=
2
)
.
first
()
if
is_cms_send
is
not
None
and
is_cms_send
.
value
==
'N'
:
...
...
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