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
381cf7e0
authored
2021-04-06 17:10:33 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add diff value
1 parent
1afcdc4a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
14 deletions
src/apps/doc/ocr/gcap.py
src/celery_compare/tasks.py
src/apps/doc/ocr/gcap.py
View file @
381cf7e
...
...
@@ -45,8 +45,8 @@ class GCAP:
'customerType'
:
'TCDAS'
,
'customerChineseName'
:
'co-app-name'
,
'idNum'
:
'idNum'
,
'idExpiryDate'
:
'2020-02-02
T15:52:18.1049637+08:00
'
,
'dateOfBirth'
:
'2020-02-02
T15:52:18.1049637+08:00
'
,
'idExpiryDate'
:
'2020-02-02'
,
'dateOfBirth'
:
'2020-02-02'
,
'customerChineseNameResult'
:
'Y'
,
'idNumResult'
:
'Y'
,
'secondIdNumResult'
:
'Y'
,
...
...
@@ -59,8 +59,8 @@ class GCAP:
'customerType'
:
'TCDAS'
,
'customerChineseName'
:
'ga1-name'
,
'idNum'
:
'id3'
,
'idExpiryDate'
:
'2020-03-03
T15:52:18.1049637+08:00
'
,
'dateOfBirth'
:
'2020-03-03
T15:52:18.1049637+08:00
'
,
'idExpiryDate'
:
'2020-03-03'
,
'dateOfBirth'
:
'2020-03-03'
,
'customerChineseNameResult'
:
'Y'
,
'idNumResult'
:
'Y'
,
'secondIdNumResult'
:
'Y'
,
...
...
@@ -73,8 +73,8 @@ class GCAP:
'customerType'
:
'TCDAS'
,
'customerChineseName'
:
'ga2-name'
,
'idNum'
:
'id4'
,
'idExpiryDate'
:
'2020-04-04
T15:52:18.1049637+08:00
'
,
'dateOfBirth'
:
'2020-04-04
T15:52:18.1049637+08:00
'
,
'idExpiryDate'
:
'2020-04-04'
,
'dateOfBirth'
:
'2020-04-04'
,
'customerChineseNameResult'
:
'Y'
,
'idNumResult'
:
'Y'
,
'secondIdNumResult'
:
'Y'
,
...
...
@@ -84,8 +84,8 @@ class GCAP:
],
'usedCarInfo'
:
{
'vinNo'
:
'LBVSFJSDLFJLSDJF'
,
'manufactureDate'
:
'2020-09-03
T15:52:18.1049637+08:00
'
,
'firstRegistrationDate'
:
'2020-09-03
T15:52:18.1049637+08:00
'
,
'manufactureDate'
:
'2020-09-03'
,
'firstRegistrationDate'
:
'2020-09-03'
,
'vinNoResult'
:
'Y'
,
'manufactureDateResult'
:
'Y'
,
'firstRegistrationDateResult'
:
'Y'
,
...
...
@@ -97,8 +97,8 @@ class GCAP:
'customerType'
:
'TCCOR'
,
'businessLicenseNo'
:
'MA007438143XJ1P'
,
'taxRegistrationCode'
:
'MA007438143XJ1P'
,
'incorporationDate'
:
'2020-09-02
T15:52:18.1049637+08:00
'
,
'businessLicenseDueDate'
:
'2020-09-02
T15:52:18.1049637+08:00
'
,
'incorporationDate'
:
'2020-09-02'
,
'businessLicenseDueDate'
:
'2020-09-02'
,
'capitalRegAmount'
:
'60000000'
,
'customerChinessNameResult'
:
'Y'
,
'legalRepNameResult'
:
'Y'
,
...
...
src/celery_compare/tasks.py
View file @
381cf7e
...
...
@@ -22,8 +22,9 @@ def get_order_dict(src_dict, order_tuple):
return
order_dict
def
field_compare
(
info_dict
,
ocr_res_dict
,
ocr_field
,
compare_list
,
res_set
):
def
field_compare
(
info_dict
,
ocr_res_dict
,
ocr_field
,
compare_list
,
res_set
,
diff_idx
=
None
):
is_find
=
False
find_dict
=
{}
ocr_res_str
=
ocr_res_dict
.
get
(
ocr_field
)
if
ocr_res_str
is
not
None
:
ocr_res_list
=
json
.
loads
(
ocr_res_str
)
...
...
@@ -37,12 +38,28 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set):
if
idx
==
0
and
compare_res
==
consts
.
RESULT_N
and
res_len
!=
1
:
break
is_find
=
True
find_dict
=
ocr_res
info_dict
[
compare_tuple
[
0
]
+
'Result'
]
=
compare_res
res_set
.
add
(
compare_res
)
if
not
is_find
:
res_set
.
add
(
consts
.
RESULT_N
)
for
compare_tuple
in
compare_list
:
info_dict
[
compare_tuple
[
0
]
+
'Result'
]
=
consts
.
RESULT_N
if
diff_idx
is
not
None
:
diff_field
=
compare_list
[
diff_idx
][
0
]
+
'Result'
if
info_dict
.
get
(
diff_field
)
==
consts
.
RESULT_N
:
if
is_find
:
diff_value
=
find_dict
.
get
(
compare_list
[
diff_idx
][
1
],
consts
.
RESULT_N
)
elif
ocr_res_str
is
not
None
:
for
ocr_res
in
ocr_res_list
:
if
ocr_res
.
get
(
compare_list
[
diff_idx
][
1
]):
diff_value
=
ocr_res
.
get
(
compare_list
[
diff_idx
][
1
])
break
else
:
diff_value
=
consts
.
RESULT_N
else
:
diff_value
=
consts
.
RESULT_N
info_dict
[
diff_field
]
=
diff_value
@app.task
...
...
@@ -98,7 +115,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
order_individual_cus_info
=
get_order_dict
(
individual_cus_info
,
consts
.
IN_ORDER
)
# sep营业执照
if
is_sep
and
order_individual_cus_info
.
get
(
'companyName'
)
is
not
None
:
field_compare
(
order_individual_cus_info
,
ocr_res_dict
,
consts
.
BL_OCR_FIELD
,
consts
.
TCSEP
,
res_set
)
field_compare
(
order_individual_cus_info
,
ocr_res_dict
,
consts
.
BL_OCR_FIELD
,
consts
.
TCSEP
,
res_set
,
2
)
# 个人信息证件
id_type
=
order_individual_cus_info
.
get
(
'idType'
)
...
...
@@ -115,10 +132,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
usedcar_info
=
json
.
loads
(
last_obj
.
usedcar_info
)
order_usedcar_info
=
get_order_dict
(
usedcar_info
,
consts
.
UC_ORDER
)
field_compare
(
order_usedcar_info
,
ocr_res_dict
,
consts
.
MVC_OCR_FIELD
,
consts
.
PCUSD_MVC
,
res_set
)
field_compare
(
order_usedcar_info
,
ocr_res_dict
,
consts
.
MVC_OCR_FIELD
,
consts
.
PCUSD_MVC
,
res_set
,
0
)
if
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]
+
'Result'
]
==
consts
.
RESULT_Y
:
field_compare
(
order_usedcar_info
,
ocr_res_dict
,
consts
.
DL_OCR_FIELD
,
consts
.
PCUSD_DL
,
res_set
)
field_compare
(
order_usedcar_info
,
ocr_res_dict
,
consts
.
DL_OCR_FIELD
,
consts
.
PCUSD_DL
,
res_set
,
0
)
comparison_res
[
'OCR_Input'
][
'usedCarInfo'
]
=
order_usedcar_info
...
...
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