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
12a2684f
authored
2021-07-12 15:51:19 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
se compare part 8
1 parent
d777eccb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
186 additions
and
48 deletions
src/apps/doc/consts.py
src/common/tools/comparison.py
src/common/tools/mssql_script6.py
src/apps/doc/consts.py
View file @
12a2684
...
...
@@ -1253,10 +1253,9 @@ SE_SEP_FIELD = [
(
'selfEmployedSubType'
,
'organizationType'
)
]
SE_CORPORATE_FIELD
=
[
'companyName'
,
'legalRepName'
,
'businessLicenseNo'
,
'organizationCreditCode'
,
'taxRegistrationCertificateNo'
,
'establishmentDate'
,
'businessLicenseDueDate'
,
'organizationType'
]
'taxRegistrationCertificateNo'
,
'establishmentDate'
,
'businessLicenseDueDate'
]
SE_CORPORATE_ALL_FIELD
=
[
'companyName'
,
'legalRepName'
,
'firstIdNo'
,
'businessLicenseNo'
,
'organizationCreditCode'
,
'taxRegistrationCertificateNo'
,
'establishmentDate'
,
'businessLicenseDueDate'
,
'organizationType'
]
'taxRegistrationCertificateNo'
,
'establishmentDate'
,
'businessLicenseDueDate'
]
SE_NEW_FIELD
=
[
'vinNo'
,
'dealer'
,
'vehicleTransactionAmount'
]
SE_USED_FIELD
=
[
'vinNo'
,
'vehicleTransactionAmount'
]
SE_NEW_ADD_FIELD
=
[
'customerName'
,
'idNum'
,
'dateOfInvoice'
]
...
...
@@ -1281,76 +1280,76 @@ BC_EN = 'Bank Card'
DDA_EN
=
'DDA'
ID_COMPARE_LOGIC
=
{
'customerName'
:
(
'姓名'
,
),
'idNum'
:
(
'公民身份号码'
,
),
'dateOfBirth'
:
(
'出生年月'
,
),
'idExpiryDate'
:
(
'有效期限'
,
),
'hukouProvince'
:
(
'住址'
,
),
'hukouCity'
:
(
'住址'
,
),
'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'
:
''
}
),
'hukouProvince'
:
(
'住址'
,
'se_contain_compare'
,
{}
),
'hukouCity'
:
(
'住址'
,
'se_contain_compare'
,
{}
),
}
PP_COMPARE_LOGIC
=
{
'customerName'
:
(
'英文姓名'
,
),
'idNum'
:
(
'护照号码'
,
),
'dateOfBirth'
:
(
'出生日期'
,
),
'idExpiryDate'
:
(
'有效期至'
,
),
'customerName'
:
(
'英文姓名'
,
'se_name_compare'
,
{
'is_passport'
:
True
}
),
'idNum'
:
(
'护照号码'
,
'se_common_compare'
,
{}
),
'dateOfBirth'
:
(
'出生日期'
,
'se_date_compare'
,
{
'input_replace'
:
''
}
),
'idExpiryDate'
:
(
'有效期至'
,
'se_date_compare'
,
{
'input_replace'
:
''
}
),
}
EEP_COMPARE_LOGIC
=
{
'customerName'
:
(
'中文名'
,
),
'idNum'
:
(
'证件号码'
,
),
'dateOfBirth'
:
(
'出生日期'
,
),
'idExpiryDate'
:
(
'有效期限'
,
),
'customerName'
:
(
'中文名'
,
'se_common_compare'
,
{}
),
'idNum'
:
(
'证件号码'
,
'se_common_compare'
,
{}
),
'dateOfBirth'
:
(
'出生日期'
,
'se_date_compare'
,
{
'input_replace'
:
'.'
}
),
'idExpiryDate'
:
(
'有效期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'input_replace'
:
'.'
}
),
}
RP_COMPARE_LOGIC
=
{
'customerName'
:
(
'姓名'
,
),
'idNum'
:
(
'公民身份号码'
,
),
'dateOfBirth'
:
(
'出生年月'
,
),
'idExpiryDate'
:
(
'有效期限'
,
),
'hukouProvince'
:
(
'住址'
,
),
'hukouCity'
:
(
'住址'
,
),
'customerName'
:
(
'姓名'
,
'se_name_compare'
,
{}
),
'idNum'
:
(
'公民身份号码'
,
'se_common_compare'
,
{}
),
'dateOfBirth'
:
(
'出生年月'
,
'se_date_compare'
,
{
'input_replace'
:
''
}
),
'idExpiryDate'
:
(
'有效期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'input_replace'
:
''
}
),
'hukouProvince'
:
(
'住址'
,
'se_contain_compare'
,
{}
),
'hukouCity'
:
(
'住址'
,
'se_contain_compare'
,
{}
),
}
BL_COMPARE_LOGIC
=
{
'companyName'
:
(
'企业名称'
,
),
'legalRepName'
:
(
'经营者姓名'
,
),
'firstIdNo'
:
(
'注册号'
,
),
'businessLicenseNo'
:
(
'注册号'
,
),
'organizationCreditCode'
:
(
'注册号'
,
),
'taxRegistrationCertificateNo'
:
(
'注册号'
,
),
'establishmentDate'
:
(
'成立日期'
,
),
'businessLicenseDueDate'
:
(
'营业期限'
,
),
'organizationType'
:
(
'企业类型'
,
),
'registeredCapital'
:
(
'注册资本'
,
),
'companyName'
:
(
'企业名称'
,
'se_company_compare'
,
{}
),
'legalRepName'
:
(
'经营者姓名'
,
'se_name_compare'
,
{}
),
'firstIdNo'
:
(
'注册号'
,
'se_common_compare'
,
{}
),
'businessLicenseNo'
:
(
'注册号'
,
'se_common_compare'
,
{}
),
'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
}
),
'organizationType'
:
(
'企业类型'
,
'se_type_compare'
,
{}
),
'registeredCapital'
:
(
'注册资本'
,
'se_rmb_compare'
,
{}
),
}
MVI_COMPARE_LOGIC
=
{
'vinNo'
:
(
'车辆识别代码'
,
),
'dealer'
:
(
'销方名称'
,
),
'vehicleTransactionAmount'
:
(
'价税合计小写'
,
),
'customerName'
:
(
'购方名称'
,
),
'idNum'
:
(
'购买方身份证号或组织机构代码'
,
),
'dateOfInvoice'
:
(
'开票日期'
,
),
'vinNo'
:
(
'车辆识别代码'
,
'se_common_compare'
,
{}
),
'dealer'
:
(
'销方名称'
,
'se_common_compare'
,
{}
),
'vehicleTransactionAmount'
:
(
'价税合计小写'
,
'se_amount_compare'
,
{}
),
'customerName'
:
(
'购方名称'
,
'se_name_compare'
,
{}
),
'idNum'
:
(
'购买方身份证号或组织机构代码'
,
'se_common_compare'
,
{}
),
'dateOfInvoice'
:
(
'开票日期'
,
'se_date_compare'
,
{}
),
}
UCI_COMPARE_LOGIC
=
{
'vinNo'
:
(
'车架号'
,
),
'vehicleTransactionAmount'
:
(
'价税合计小写'
,
),
'customerName'
:
(
'购方名称'
,
),
'idNum'
:
(
'购方纳税人识别号'
,
),
'vinNo'
:
(
'车架号'
,
'se_common_compare'
,
{}
),
'vehicleTransactionAmount'
:
(
'价税合计小写'
,
'se_amount_compare'
,
{}
),
'customerName'
:
(
'购方名称'
,
'se_name_compare'
,
{}
),
'idNum'
:
(
'购方纳税人识别号'
,
'se_common_compare'
,
{}
),
}
MVC_COMPARE_LOGIC
=
{
'vinNo'
:
(
'9.车辆识别代号/车架号'
,
),
'vinNo'
:
(
'9.车辆识别代号/车架号'
,
'se_common_compare'
,
{}
),
# 'customerName': ('姓名/名称', ),
# 'idNum': ('身份证明名称/号码', ),
# 'date': ('转移登记日期', ),
}
BC_COMPARE_LOGIC
=
{
'accountNo'
:
(
'CardNum'
,
),
'bankName'
:
(
'BankName'
,
),
'accountNo'
:
(
'CardNum'
,
'se_common_compare'
,
{}
),
'bankName'
:
(
'BankName'
,
'se_common_compare'
,
{}
),
}
DDA_COMPARE_LOGIC
=
{
...
...
src/common/tools/comparison.py
View file @
12a2684
import
re
from
datetime
import
datetime
#
from .rmb_lower import rmb_handler
from
.rmb_upper
import
to_rmb_upper
from
.rmb_lower
import
rmb_handler
#
from .rmb_upper import to_rmb_upper
class
Comparison
:
...
...
@@ -136,6 +136,85 @@ class Comparison:
return
self
.
build_res
(
input_str
==
compare_str
),
compare_str
def
se_name_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
if
kwargs
.
get
(
'is_passport'
):
input_tmp
=
input_str
.
upper
()
.
replace
(
' '
,
''
)
ocr_tmp
=
ocr_str
.
upper
()
.
replace
(
' '
,
''
)
if
input_tmp
.
find
(
ocr_tmp
)
==
-
1
:
return
self
.
RESULT_N
else
:
return
self
.
RESULT_Y
else
:
# if re.search(r'[a-zA-Z]]', input_str):
# return self.RESULT_NA, ocr_str
input_s
=
input_str
.
translate
(
self
.
TRANS
)
ocr_s
=
ocr_str
.
translate
(
self
.
TRANS
)
return
self
.
build_res
(
input_s
==
ocr_s
)
def
se_common_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
return
self
.
build_res
(
input_str
==
ocr_str
)
def
se_date_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
if
kwargs
.
get
(
'long'
,
False
):
if
'长期'
in
ocr_str
or
'永久'
in
ocr_str
:
if
input_str
in
[
'2099-12-31'
,
'2099-01-01'
,
'2999-12-31'
,
'2999-01-01'
]:
return
self
.
RESULT_Y
else
:
return
self
.
RESULT_N
if
kwargs
.
get
(
'ocr_split'
,
False
):
if
'至'
in
ocr_str
:
ocr_str
=
ocr_str
.
split
(
'至'
)[
-
1
]
elif
'-'
in
ocr_str
:
ocr_str
=
ocr_str
.
split
(
'-'
)[
-
1
]
if
kwargs
.
get
(
'ocr_replace'
,
False
):
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
)
def
se_contain_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
if
ocr_str
.
find
(
input_str
)
==
-
1
:
return
self
.
RESULT_N
else
:
return
self
.
RESULT_Y
def
se_amount_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
if
input_str
==
ocr_str
:
return
self
.
RESULT_Y
else
:
try
:
float_input
=
float
(
input_str
)
float_ocr
=
float
(
ocr_str
)
except
Exception
as
e
:
return
self
.
RESULT_N
else
:
return
self
.
build_res
(
float_ocr
==
float_input
)
def
se_company_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
input_tmp
=
re
.
sub
(
self
.
re_obj
,
''
,
input_str
)
.
strip
()
ocr_tmp
=
re
.
sub
(
self
.
re_obj
,
''
,
ocr_str
)
.
strip
()
return
self
.
build_res
(
input_tmp
==
ocr_tmp
)
def
se_rmb_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
try
:
ocr_lower
=
rmb_handler
.
to_rmb_lower
(
ocr_str
)
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
else
:
return
res
def
se_type_compare
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
for
map_tuple
in
self
.
TYPE_MAPPING
:
if
re
.
search
(
map_tuple
[
0
],
ocr_str
)
is
not
None
:
compare_str
=
map_tuple
[
1
]
break
else
:
compare_str
=
self
.
CSOTH
return
self
.
build_res
(
input_str
==
compare_str
)
cp
=
Comparison
()
...
...
src/common/tools/mssql_script6.py
View file @
12a2684
...
...
@@ -2,6 +2,36 @@ import pyodbc
hil_sql
=
"""
create table hil_se_comparison_info
(
id bigint identity primary key,
uniq_seq nvarchar(128) not null,
application_id nvarchar(64) not null,
application_version tinyint default 0 not null,
customer_type nvarchar(16) not null,
first_submmison_date nvarchar(16) not null,
property_doc_policy nvarchar(16),
individual_cus_info nvarchar(max) not null,
corporate_cus_info nvarchar(max),
vehicle_info nvarchar(max) not null,
insurance_info nvarchar(max) not null,
bank_info nvarchar(max) not null,
quotationt_info nvarchar(max) not null,
update_time datetime not null,
create_time datetime not null
);
create index hil_se_comparison_info_application_id_index
on hil_se_comparison_info (application_id);
create index hil_se_comparison_info_create_time_index
on hil_se_comparison_info (create_time);
create index hil_se_comparison_info_uniq_seq_index
on hil_se_comparison_info (uniq_seq);
create table hil_se_ocr_result
(
id int identity primary key,
...
...
@@ -83,6 +113,36 @@ hil_sql = """
"""
afc_sql
=
"""
create table afc_se_comparison_info
(
id bigint identity primary key,
uniq_seq nvarchar(128) not null,
application_id nvarchar(64) not null,
application_version tinyint default 0 not null,
customer_type nvarchar(16) not null,
first_submmison_date nvarchar(16) not null,
property_doc_policy nvarchar(16),
individual_cus_info nvarchar(max) not null,
corporate_cus_info nvarchar(max),
vehicle_info nvarchar(max) not null,
insurance_info nvarchar(max) not null,
bank_info nvarchar(max) not null,
quotationt_info nvarchar(max) not null,
update_time datetime not null,
create_time datetime not null
);
create index afc_se_comparison_info_application_id_index
on afc_se_comparison_info (application_id);
create index afc_se_comparison_info_create_time_index
on afc_se_comparison_info (create_time);
create index afc_se_comparison_info_uniq_seq_index
on afc_se_comparison_info (uniq_seq);
create table afc_se_ocr_result
(
id int identity primary key,
...
...
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