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
19f10814
authored
2021-09-02 18:17:10 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
se compare part 1
1 parent
04c50d1f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
13 deletions
src/apps/doc/consts.py
src/celery_compare/tasks.py
src/common/tools/comparison.py
src/apps/doc/consts.py
View file @
19f1081
...
...
@@ -1347,7 +1347,7 @@ ID_COMPARE_LOGIC = {
'customerName'
:
(
'姓名'
,
'se_name_compare'
,
{}),
'idNum'
:
(
'公民身份号码'
,
'se_common_compare'
,
{}),
'dateOfBirth'
:
(
'出生年月'
,
'se_date_compare'
,
{
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期限'
,
'se_date_compare'
,
{
'long'
:
True
,
'ocr_split'
:
True
,
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期限'
,
'se_date_compare'
,
{
'long'
:
True
,
'ocr_split'
:
True
,
'input_replace'
:
''
,
'today'
:
True
}),
'hukouProvince'
:
(
'住址'
,
'se_contain_compare'
,
{}),
'hukouCity'
:
(
'住址'
,
'se_contain_compare'
,
{}),
}
...
...
@@ -1356,21 +1356,21 @@ PP_COMPARE_LOGIC = {
'customerName'
:
(
'英文姓名'
,
'se_name_compare'
,
{
'is_passport'
:
True
}),
'idNum'
:
(
'护照号码'
,
'se_common_compare'
,
{}),
'dateOfBirth'
:
(
'出生日期'
,
'se_date_compare'
,
{
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期至'
,
'se_date_compare'
,
{
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期至'
,
'se_date_compare'
,
{
'input_replace'
:
''
,
'today'
:
True
}),
}
EEP_COMPARE_LOGIC
=
{
'customerName'
:
(
'中文名'
,
'se_common_compare'
,
{}),
'idNum'
:
(
'证件号码'
,
'se_common_compare'
,
{}),
'dateOfBirth'
:
(
'出生日期'
,
'se_date_compare'
,
{
'input_replace'
:
'.'
}),
'idExpiryDate'
:
(
'有效期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'input_replace'
:
'.'
}),
'idExpiryDate'
:
(
'有效期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'input_replace'
:
'.'
,
'today'
:
True
}),
}
RP_COMPARE_LOGIC
=
{
'customerName'
:
(
'姓名'
,
'se_name_compare'
,
{}),
'idNum'
:
(
'公民身份号码'
,
'se_common_compare'
,
{}),
'dateOfBirth'
:
(
'出生年月'
,
'se_date_compare'
,
{
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'input_replace'
:
''
,
'today'
:
True
}),
'hukouProvince'
:
(
'住址'
,
'se_contain_compare'
,
{}),
'hukouCity'
:
(
'住址'
,
'se_contain_compare'
,
{}),
}
...
...
@@ -1383,7 +1383,7 @@ BL_COMPARE_LOGIC = {
'organizationCreditCode'
:
(
'注册号'
,
'se_common_compare'
,
{}),
'taxRegistrationCertificateNo'
:
(
'注册号'
,
'se_common_compare'
,
{}),
'establishmentDate'
:
(
'成立日期'
,
'se_date_compare'
,
{
'ocr_replace'
:
True
}),
'businessLicenseDueDate'
:
(
'营业期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'long'
:
True
,
'ocr_replace'
:
True
}),
'businessLicenseDueDate'
:
(
'营业期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'long'
:
True
,
'ocr_replace'
:
True
,
'today'
:
True
}),
'organizationType'
:
(
'企业类型'
,
'se_type_compare'
,
{}),
'registeredCapital'
:
(
'注册资本'
,
'se_rmb_compare'
,
{}),
}
...
...
@@ -1392,17 +1392,18 @@ MVI_COMPARE_LOGIC = {
'vinNo'
:
(
'车辆识别代码'
,
'se_common_compare'
,
{}),
'dealer'
:
(
'销方名称'
,
'se_common_compare'
,
{}),
'vehicleTransactionAmount'
:
(
'价税合计小写'
,
'se_amount_compare'
,
{}),
'customerName'
:
(
'购方名称'
,
'se_name_compare'
,
{}),
'customerName'
:
(
'购方名称'
,
'se_name_compare'
,
{
'is_passport'
:
True
}),
'idNum'
:
(
'购买方身份证号或组织机构代码'
,
'se_contain_compare_2'
,
{}),
'dateOfInvoice'
:
(
'开票日期'
,
'se_date_compare_2'
,
{}),
'dateOfInvoice'
:
(
'开票日期'
,
'se_date_compare_2'
,
{
'three_month'
:
True
}),
'stamp'
:
(
'销售单位章'
,
'se_common_compare'
,
{}),
}
UCI_COMPARE_LOGIC
=
{
'vinNo'
:
(
'车架号'
,
'se_common_compare'
,
{}),
'vehicleTransactionAmount'
:
(
'价税合计小写'
,
'se_amount_compare'
,
{}),
'customerName'
:
(
'购方名称'
,
'se_name_compare'
,
{}),
'customerName'
:
(
'购方名称'
,
'se_name_compare'
,
{
'is_passport'
:
True
}),
'idNum'
:
(
'购方纳税人识别号'
,
'se_contain_compare_2'
,
{}),
'dateOfInvoice'
:
(
'开票日期'
,
'se_date_compare_2'
,
{
'three_month'
:
True
}),
'stamp'
:
(
'发票章'
,
'se_common_compare'
,
{}),
}
...
...
src/celery_compare/tasks.py
View file @
19f1081
...
...
@@ -821,6 +821,7 @@ def get_se_compare_info(last_obj, application_entity):
gb34_field_input
.
append
((
consts
.
SE_GB_USED_FIELD
[
0
],
main_name
))
gb34_field_input
.
append
((
consts
.
SE_GB_USED_FIELD
[
1
],
main_num
))
gb34_field_input
.
append
((
consts
.
SE_GB_USED_FIELD
[
2
],
last_obj
.
first_submmison_date
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
2
],
last_obj
.
first_submmison_date
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
3
],
consts
.
SE_STAMP_VALUE
))
vehicle_info
[
consts
.
UCI_EN
]
=
vehicle_field_input
vehicle_info
[
consts
.
MVC_EN
]
=
gb_field_input
...
...
src/common/tools/comparison.py
View file @
19f1081
import
re
import
time
import
numpy
as
np
from
datetime
import
datetime
from
dateutil.relativedelta
import
relativedelta
from
.rmb_lower
import
rmb_handler
# from .rmb_upper import to_rmb_upper
from
pandas._libs
import
tslib
from
pandas._libs.tslibs.nattype
import
NaTType
from
pandas.core.indexes.datetimes
import
DatetimeIndex
class
Comparison
:
...
...
@@ -179,10 +184,27 @@ class Comparison:
def
ca_common_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
return
self
.
build_res
(
input_str
==
ocr_str
)
@staticmethod
def
is_after_today
(
ocr_str
):
dt_array
,
_
=
tslib
.
array_to_datetime
(
np
.
array
([
ocr_str
,
],
copy
=
False
,
dtype
=
np
.
object_
),
errors
=
"coerce"
,
utc
=
False
,
dayfirst
=
False
,
yearfirst
=
False
,
require_iso8601
=
True
,
)
dti
=
DatetimeIndex
(
dt_array
,
tz
=
None
,
name
=
None
)
ts
=
dti
[
0
]
if
isinstance
(
ts
,
NaTType
)
or
ts
.
date
()
<
datetime
.
today
()
.
date
():
return
False
else
:
return
True
def
se_date_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
if
kwargs
.
get
(
'long'
,
False
):
if
'长期'
in
ocr_str
or
'永久'
in
ocr_str
or
'***'
in
ocr_str
or
'至今'
in
ocr_str
:
if
input_str
in
[
'2099-12-31'
,
'2099-01-01'
,
'2999-12-31'
,
'2999-01-01'
]:
if
kwargs
.
get
(
'today'
,
False
)
or
input_str
in
[
'2099-12-31'
,
'2099-01-01'
,
'2999-12-31'
,
'2999-01-01'
]:
return
self
.
RESULT_Y
else
:
return
self
.
RESULT_N
...
...
@@ -195,7 +217,10 @@ class Comparison:
ocr_str
=
ocr_str
.
replace
(
'年'
,
'-'
)
.
replace
(
'月'
,
'-'
)
.
replace
(
'日'
,
''
)
if
kwargs
.
get
(
'input_replace'
)
is
not
None
:
input_str
=
input_str
.
replace
(
'-'
,
kwargs
.
get
(
'input_replace'
))
return
self
.
build_res
(
input_str
==
ocr_str
)
if
kwargs
.
get
(
'today'
,
False
):
return
self
.
build_res
(
self
.
is_after_today
(
ocr_str
))
else
:
return
self
.
build_res
(
input_str
==
ocr_str
)
def
ca_date_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
if
kwargs
.
get
(
'long'
,
False
):
...
...
@@ -306,12 +331,17 @@ class Comparison:
def
se_date_compare_2
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
try
:
input_date
=
time
.
strptime
(
input_str
,
"
%
Y-
%
m-
%
d"
)
ocr_date
=
time
.
strptime
(
ocr_str
,
"
%
Y-
%
m-
%
d"
)
input_date
=
datetime
.
strptime
(
input_str
,
"
%
Y-
%
m-
%
d"
)
.
date
()
if
kwargs
.
get
(
'three_month'
,
False
):
three_month_date
=
(
datetime
.
today
()
-
relativedelta
(
months
=
3
))
.
date
()
compare_date
=
max
(
input_date
,
three_month_date
)
else
:
compare_date
=
input_date
ocr_date
=
datetime
.
strptime
(
ocr_str
,
"
%
Y-
%
m-
%
d"
)
.
date
()
except
Exception
as
e
:
return
self
.
RESULT_N
else
:
return
self
.
build_res
(
input
_date
<=
ocr_date
)
return
self
.
build_res
(
compare
_date
<=
ocr_date
)
cp
=
Comparison
()
...
...
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