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
634fd497
authored
2022-01-17 17:03:46 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix auto
1 parent
0c6d8799
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
src/apps/doc/views.py
src/celery_compare/tasks.py
src/apps/doc/views.py
View file @
634fd49
...
...
@@ -508,7 +508,7 @@ result_update_args = {
}
mpos_args
=
{
'type'
:
fields
.
Int
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
MPOS_MAP
.
keys
()
)),
'type'
:
fields
.
Int
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
MPOS_MAP
)),
'file_base64_content'
:
fields
.
List
(
fields
.
Str
(),
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
)),
}
...
...
@@ -1012,8 +1012,10 @@ class CompareResultView(GenericView):
if
result_obj
is
None
:
whole_result
=
''
latest_compared_time
=
''
else
:
whole_result
=
consts
.
RESULT_Y
if
result_obj
.
ocr_auto_result_pass
else
consts
.
RESULT_N
latest_compared_time
=
''
if
result_obj
.
ocr_latest_comparison_time
is
None
else
result_obj
.
ocr_latest_comparison_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
)
source
=
consts
.
INFO_SOURCE
[
1
]
version
=
comments
=
''
...
...
@@ -1025,11 +1027,11 @@ class CompareResultView(GenericView):
'scheme'
:
consts
.
DOC_SCHEME_LIST
[
0
]
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
consts
.
DOC_SCHEME_LIST
[
1
],
'whole_result'
:
whole_result
,
'latest_compared_time'
:
''
if
result_obj
is
None
else
result_obj
.
ocr_latest_comparison_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
)
,
'latest_compared_time'
:
latest_compared_time
,
'source'
:
source
,
'version'
:
version
,
'comments'
:
comments
,
'result'
:
[]
if
result_obj
is
None
else
json
.
loads
(
result_obj
.
ocr_auto_result
)
'result'
:
[]
if
result_obj
is
None
or
not
result_obj
.
ocr_auto_result
else
json
.
loads
(
result_obj
.
ocr_auto_result
)
}
return
response
.
ok
(
data
=
compare_result
)
...
...
src/celery_compare/tasks.py
View file @
634fd49
...
...
@@ -2720,7 +2720,7 @@ def se_result_detect(ocr_res_dict):
return
detect_list
def
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
):
def
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
,
full_result
):
try
:
# 比对逻辑
# detect_list = se_result_detect(ocr_res_dict)
...
...
@@ -2738,6 +2738,7 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc
try
:
auto_obj
.
aa_type
=
aa_type
auto_obj
.
ocr_auto_result_pass
=
successful_at_this_level
auto_obj
.
ocr_whole_result_pass
=
full_result
auto_obj
.
ocr_auto_result
=
json
.
dumps
(
compare_result
)
auto_obj
.
ocr_latest_comparison_time
=
datetime
.
now
()
auto_obj
.
save
()
...
...
@@ -2769,6 +2770,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
compare_log
.
error
(
'{0} [SE] [compare 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
False
else
:
# 将比对结果写入数据库
try
:
...
...
@@ -2844,6 +2846,8 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
'[response={5}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
data
,
response
))
return
successful_at_this_level
@app.task
def
compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
,
is_cms
=
False
):
...
...
@@ -2902,10 +2906,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
tmp_se_result
=
json
.
loads
(
ocr_res_dict
.
get
(
field_name
))
tmp_ca_result
.
extend
(
tmp_se_result
)
ocr_res_dict
[
field_name
]
=
json
.
dumps
(
tmp_ca_result
)
full_result
=
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
)
# auto settlement
auto_class
=
HILAutoSettlement
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCAutoSettlement
auto_obj
=
auto_class
.
objects
.
filter
(
application_id
=
application_id
,
on_off
=
True
)
.
first
()
if
auto_obj
is
not
None
:
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
)
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
is_cms
)
se_compare_auto
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
,
auto_obj
,
full_result
)
...
...
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