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
23c4a341
authored
2021-05-20 16:53:19 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ca compare fix back
1 parent
7890be8a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
38 deletions
src/celery_compare/tasks.py
src/common/tools/comparison.py
src/celery_compare/tasks.py
View file @
23c4a34
...
...
@@ -30,30 +30,33 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has
ocr_res_str
=
ocr_res_dict
.
get
(
ocr_field
)
if
ocr_res_str
is
not
None
:
ocr_res_list
=
json
.
loads
(
ocr_res_str
)
# sep营业执照根据法人过滤
if
isinstance
(
sep_name
,
str
):
tmp_list
=
[]
for
ocr_res
in
ocr_res_list
:
ocr_sep_name
=
ocr_res
.
get
(
consts
.
LEGAL_REP_NAME
)
if
isinstance
(
ocr_sep_name
,
str
)
and
ocr_sep_name
==
sep_name
:
tmp_list
.
append
(
ocr_res
)
else
:
tmp_list
=
ocr_res_list
length
=
len
(
tmp_list
)
length
=
len
(
ocr_res_list
)
# # sep营业执照根据法人过滤
# if isinstance(sep_name, str):
# tmp_list = []
# for ocr_res in ocr_res_list:
# ocr_sep_name = ocr_res.get(consts.LEGAL_REP_NAME)
# if isinstance(ocr_sep_name, str) and ocr_sep_name == sep_name:
# tmp_list.append(ocr_res)
# else:
# tmp_list = ocr_res_list
#
# length = len(tmp_list)
# 过期期限特殊处理
if
has_expiry_date
:
expiry_dates
=
[]
key
=
compare_list
[
2
][
1
]
for
ocr_res
in
tmp_list
:
# for ocr_res in tmp_list:
for
ocr_res
in
ocr_res_list
:
if
ocr_res
.
get
(
key
):
expiry_dates
.
append
(
ocr_res
.
get
(
key
))
else
:
expiry_dates
=
[]
for
ocr_res
in
tmp_list
:
# for ocr_res in tmp_list:
for
ocr_res
in
ocr_res_list
:
if
is_find
:
break
for
idx
,
compare_tuple
in
enumerate
(
compare_list
):
...
...
@@ -201,15 +204,15 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
for
individual_cus_info
in
individual_cus_info_list
:
order_individual_cus_info
=
get_order_dict
(
individual_cus_info
,
consts
.
IN_ORDER
)
# 获取sep下营业执照法人代表
if
order_individual_cus_info
.
get
(
'customerType'
)
==
consts
.
CUSTOMER_TYPE
[
5
]:
sep_name
=
order_individual_cus_info
.
get
(
'customerChineseName'
)
if
isinstance
(
sep_name
,
str
):
sep_name
=
sep_name
.
strip
()
if
sep_name
==
''
:
sep_name
=
None
else
:
sep_name
=
None
#
#
获取sep下营业执照法人代表
#
if order_individual_cus_info.get('customerType') == consts.CUSTOMER_TYPE[5]:
#
sep_name = order_individual_cus_info.get('customerChineseName')
#
if isinstance(sep_name, str):
#
sep_name = sep_name.strip()
#
if sep_name == '':
#
sep_name = None
#
else:
#
sep_name = None
# 个人信息证件
id_type
=
order_individual_cus_info
.
get
(
'idType'
)
...
...
@@ -235,8 +238,9 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
# sep营业执照
if
order_individual_cus_info
.
get
(
'customerType'
)
==
consts
.
CUSTOMER_TYPE
[
5
]:
field_compare
(
order_individual_cus_info
,
ocr_res_dict
,
consts
.
BL_OCR_FIELD
,
consts
.
TCSEP
,
res_set
,
sep_name
=
sep_name
)
# field_compare(order_individual_cus_info, ocr_res_dict, consts.BL_OCR_FIELD, consts.TCSEP, res_set,
# sep_name=sep_name)
field_compare
(
order_individual_cus_info
,
ocr_res_dict
,
consts
.
BL_OCR_FIELD
,
consts
.
TCSEP
,
res_set
)
order_individual_cus_info_list
.
append
(
order_individual_cus_info
)
...
...
@@ -253,21 +257,38 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
dl_find
,
dl_vinos
=
usedcar_info_compare
(
order_usedcar_info
,
ocr_res_dict
,
consts
.
DL_OCR_FIELD
,
consts
.
PCUSD_DL
,
res_set
)
# if mvc_find is True and dl_find is False:
# vino = dl_vinos[-1] if len(dl_vinos) > 0 else ''
# order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}: {1}'.format(consts.PREFIX_MVC, vino)
# order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N
# elif mvc_find is False and dl_find is True:
# vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else ''
# order_usedcar_info[consts.PCUSD_MVC[0][0]] = '{0}: {1}'.format(consts.PREFIX_DL, vino)
# order_usedcar_info[consts.PCUSD_MVC[0][4]] = consts.RESULT_N
# elif mvc_find is False and dl_find is False:
# vino_list = []
# mvc_vino = mvc_vinos[-1] if len(mvc_vinos) > 0 else ''
# dl_vino = dl_vinos[-1] if len(dl_vinos) > 0 else ''
# vino_list.append('{0}: {1}'.format(consts.PREFIX_MVC, mvc_vino))
# vino_list.append(dl_vinos[-1])
# vino = '、'.join('{0}: {1}'.format(consts.PREFIX_DL, dl_vino))
# order_usedcar_info[consts.PCUSD_MVC[0][0]] = vino
if
mvc_find
is
True
and
dl_find
is
False
:
vino
=
dl_vinos
[
-
1
]
if
len
(
dl_vinos
)
>
0
else
''
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
'{0}: {1}'
.
format
(
consts
.
PREFIX_MVC
,
vino
)
vino
=
dl_vinos
[
0
]
if
len
(
dl_vinos
)
>
0
else
''
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
vino
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
4
]]
=
consts
.
RESULT_N
elif
mvc_find
is
False
and
dl_find
is
True
:
vino
=
mvc_vinos
[
-
1
]
if
len
(
mvc_vinos
)
>
0
else
''
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
'{0}: {1}'
.
format
(
consts
.
PREFIX_DL
,
vino
)
vino
=
mvc_vinos
[
0
]
if
len
(
mvc_vinos
)
>
0
else
''
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
vino
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
4
]]
=
consts
.
RESULT_N
elif
mvc_find
is
False
and
dl_find
is
False
:
vino_list
=
[]
mvc_vino
=
mvc_vinos
[
-
1
]
if
len
(
mvc_vinos
)
>
0
else
''
dl_vino
=
dl_vinos
[
-
1
]
if
len
(
dl_vinos
)
>
0
else
''
vino_list
.
append
(
'{0}: {1}'
.
format
(
consts
.
PREFIX_MVC
,
mvc_vino
))
vino_list
.
append
(
dl_vinos
[
-
1
])
vino
=
'、'
.
join
(
'{0}: {1}'
.
format
(
consts
.
PREFIX_DL
,
dl_vino
)
)
if
len
(
mvc_vinos
)
>
0
:
vino_list
.
append
(
mvc_vinos
[
0
])
if
len
(
dl_vinos
)
>
0
:
vino_list
.
append
(
dl_vinos
[
0
])
vino
=
'、'
.
join
(
vino_list
)
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
vino
comparison_res
[
'OCR_Input'
][
'usedCarInfo'
]
=
order_usedcar_info
...
...
src/common/tools/comparison.py
View file @
23c4a34
import
re
from
datetime
import
datetime
from
.rmb_lower
import
rmb_handler
# from .rmb_lower import rmb_handler
from
.rmb_upper
import
to_rmb_upper
class
Comparison
:
...
...
@@ -108,15 +109,18 @@ class Comparison:
if
ocr_str
==
''
or
ocr_str
.
strip
()
==
''
:
return
self
.
RESULT_NA
,
None
try
:
ocr_lower
=
rmb_handler
.
to_rmb_lower
()
res
=
self
.
build_res
(
float
(
input_str
)
==
ocr_lower
)
# ocr_lower = rmb_handler.to_rmb_lower()
# res = self.build_res(float(input_str) == ocr_lower)
input_rmb_upper
=
to_rmb_upper
(
float
(
input_str
))
res
=
self
.
build_res
(
input_rmb_upper
==
ocr_str
)
except
Exception
as
e
:
return
self
.
RESULT_N
,
None
else
:
if
res
==
self
.
RESULT_Y
:
return
res
,
input_str
else
:
return
res
,
ocr_lower
# return res, ocr_lower
return
res
,
None
def
type_compare
(
self
,
input_str
,
ocr_str
,
idx
,
**
kwargs
):
if
not
isinstance
(
ocr_str
,
str
)
or
not
isinstance
(
input_str
,
str
):
...
...
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