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
35db299e
authored
2021-08-27 18:23:42 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
slice1 part2
1 parent
254938ba
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
497 additions
and
38 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/models.py
src/apps/doc/views.py
src/celery_compare/tasks.py
src/common/tools/comparison.py
src/common/tools/mssql_script7.py
src/settings/conf/prd.ini
src/settings/conf/sit.ini
src/settings/conf/uat.ini
src/apps/doc/consts.py
View file @
35db299
...
...
@@ -1449,7 +1449,112 @@ SE_SECOND_ID_FIELD_MAPPING = {
HEAD_LIST
=
[
'Info'
,
'Index'
,
'License'
,
'Field'
,
'Input'
,
'OCR'
,
'Result'
,
'Position'
,
'Image'
,
'errorType'
]
IMG_PATH_KEY
=
'uniq_img_path_key'
IMG_PATH_KEY_2
=
'uniq_img_path_key_2'
INFO_SOURCE
=
[
'POS'
,
'CMS'
]
# -------------------
CA_FIRST_ID_FIELD
=
[
'customerChineseName'
,
'idNum'
,
'idExpiryDate'
,
'dateOfBirth'
]
CA_FIRST_ID_FIELD_MAPPING
=
{
'ITPRC'
:
(
ID_EN
,
CA_FIRST_ID_FIELD
),
'ITPSP'
:
(
PP_EN
,
CA_FIRST_ID_FIELD
),
'ITHKM'
:
(
EEP_EN
,
CA_FIRST_ID_FIELD
),
'ITTID'
:
(
EEP_EN
,
CA_FIRST_ID_FIELD
),
'ITRES'
:
(
RP_EN
,
CA_FIRST_ID_FIELD
),
}
CA_SECOND_ID_FIELD
=
[
(
'customerChineseName'
,
'customerChineseName'
),
(
'secondIdNum'
,
'idNum'
)
]
CA_SECOND_ID_FIELD_MAPPING
=
{
'ITPRC'
:
(
ID_EN
,
CA_SECOND_ID_FIELD
),
'ITPSP'
:
(
PP_EN
,
CA_SECOND_ID_FIELD
),
'ITHKM'
:
(
EEP_EN
,
CA_SECOND_ID_FIELD
),
'ITTID'
:
(
EEP_EN
,
CA_SECOND_ID_FIELD
),
'ITRES'
:
(
RP_EN
,
CA_SECOND_ID_FIELD
),
}
CA_SEP_FIELD
=
[
'companyName'
,
'customerChineseName'
,
'registeredCapital'
,
'selfEmployedSubType'
]
CA_CORPORATE_FIELD
=
[
(
'customerChineseName'
,
'companyName'
),
(
'legalRepName'
,
'customerChineseName'
),
(
'idNum'
,
'idNum'
),
(
'businessLicenseNo'
,
'businessLicenseNo'
),
(
'taxRegistrationCode'
,
'taxRegistrationCode'
),
(
'incorporationDate'
,
'incorporationDate'
),
(
'businessLicenseDueDate'
,
'businessLicenseDueDate'
),
(
'capitalRegAmount'
,
'registeredCapital'
),
]
CA_MVC_FIELD
=
[
'vinNo'
,
'manufactureDate'
,
'firstRegistrationDate'
]
CA_DL_FIELD
=
[
'vinNo'
]
DL_EN
=
'Driving Licence'
CA_ID_COMPARE_LOGIC
=
{
'customerChineseName'
:
(
'姓名'
,
'ca_name_compare'
,
{}),
'idNum'
:
(
'公民身份号码'
,
'ca_common_compare'
,
{}),
'dateOfBirth'
:
(
'出生年月'
,
'ca_date_compare'
,
{
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期限'
,
'ca_date_compare'
,
{
'long'
:
True
,
'ocr_split'
:
True
,
'input_replace'
:
''
}),
}
CA_PP_COMPARE_LOGIC
=
{
'customerChineseName'
:
(
'英文姓名'
,
'ca_name_compare'
,
{
'is_passport'
:
True
}),
'idNum'
:
(
'护照号码'
,
'ca_common_compare'
,
{}),
'dateOfBirth'
:
(
'出生日期'
,
'ca_date_compare'
,
{
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期至'
,
'ca_date_compare'
,
{
'input_replace'
:
''
}),
}
CA_EEP_COMPARE_LOGIC
=
{
'customerChineseName'
:
(
'中文名'
,
'ca_common_compare'
,
{}),
'idNum'
:
(
'证件号码'
,
'ca_common_compare'
,
{}),
'dateOfBirth'
:
(
'出生日期'
,
'ca_date_compare'
,
{
'input_replace'
:
'.'
}),
'idExpiryDate'
:
(
'有效期限'
,
'ca_date_compare'
,
{
'ocr_split'
:
True
,
'input_replace'
:
'.'
}),
}
CA_RP_COMPARE_LOGIC
=
{
'customerChineseName'
:
(
'姓名'
,
'ca_common_compare'
,
{}),
'idNum'
:
(
'公民身份号码'
,
'ca_common_compare'
,
{}),
'dateOfBirth'
:
(
'出生年月'
,
'ca_date_compare'
,
{
'input_replace'
:
''
}),
'idExpiryDate'
:
(
'有效期限'
,
'ca_date_compare'
,
{
'ocr_split'
:
True
,
'input_replace'
:
''
}),
}
CA_BL_COMPARE_LOGIC
=
{
'companyName'
:
(
'企业名称'
,
'ca_company_compare'
,
{}),
'customerChineseName'
:
(
'经营者姓名'
,
'ca_name_compare'
,
{}),
'idNum'
:
(
'注册号'
,
'ca_common_compare'
,
{}),
'businessLicenseNo'
:
(
'注册号'
,
'ca_common_compare'
,
{}),
'taxRegistrationCode'
:
(
'注册号'
,
'ca_common_compare'
,
{}),
'incorporationDate'
:
(
'成立日期'
,
'ca_date_compare'
,
{
'ocr_replace'
:
True
}),
'businessLicenseDueDate'
:
(
'营业期限'
,
'ca_date_compare'
,
{
'ocr_split'
:
True
,
'long'
:
True
,
'ocr_replace'
:
True
}),
'registeredCapital'
:
(
'注册资本'
,
'ca_rmb_compare'
,
{}),
'selfEmployedSubType'
:
(
'企业类型'
,
'ca_type_compare'
,
{}),
}
CA_MVC_COMPARE_LOGIC
=
{
'vinNo'
:
(
'9.车辆识别代号/车架号'
,
'ca_common_compare'
,
{}),
'manufactureDate'
:
(
'32.车辆出厂日期'
,
'ca_date_compare'
,
{}),
'firstRegistrationDate'
:
(
'3.登记日期'
,
'ca_date_compare'
,
{}),
}
CA_DL_COMPARE_LOGIC
=
{
'vinNo'
:
(
'车辆识别代码'
,
'ca_common_compare'
,
{}),
}
CA_COMPARE_FIELD
=
{
ID_EN
:
(
IC_OCR_FIELD
,
CA_ID_COMPARE_LOGIC
,
True
),
PP_EN
:
(
PP_OCR_FIELD
,
CA_PP_COMPARE_LOGIC
,
False
),
EEP_EN
:
(
EEP_OCR_FIELD
,
CA_EEP_COMPARE_LOGIC
,
False
),
RP_EN
:
(
RP_OCR_FIELD
,
CA_RP_COMPARE_LOGIC
,
True
),
BL_EN
:
(
BL_OCR_FIELD
,
CA_BL_COMPARE_LOGIC
,
False
),
MVC_EN
:
(
MVC_OCR_FIELD
,
CA_MVC_COMPARE_LOGIC
,
False
),
DL_EN
:
(
DL_OCR_FIELD
,
CA_DL_COMPARE_LOGIC
,
False
),
}
...
...
src/apps/doc/management/commands/ocr_process.py
View file @
35db299
...
...
@@ -244,7 +244,10 @@ class Command(BaseCommand, LoggerMixin):
elif
classify
==
consts
.
IC_CLASSIFY
:
# 身份证真伪
for
id_card_dict
in
license_data
:
id_card_dict
[
consts
.
IMG_PATH_KEY
]
=
img_path
if
'有效期限'
in
id_card_dict
:
id_card_dict
[
consts
.
IMG_PATH_KEY_2
]
=
img_path
else
:
id_card_dict
[
consts
.
IMG_PATH_KEY
]
=
img_path
try
:
base64_img
=
id_card_dict
.
pop
(
'base64_img'
)
except
Exception
as
e
:
...
...
@@ -1030,7 +1033,7 @@ class Command(BaseCommand, LoggerMixin):
license_list
=
license_summary
.
get
(
classify
)
if
not
license_list
:
continue
if
classify
==
consts
.
IC_CLASSIFY
and
ic_merge
:
# TODO 正反面合并时的img_path处理
if
classify
==
consts
.
IC_CLASSIFY
and
ic_merge
:
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
elif
classify
==
consts
.
RP_CLASSIFY
and
rp_merge
:
...
...
@@ -1357,9 +1360,9 @@ class Command(BaseCommand, LoggerMixin):
finally
:
try
:
img_save_path
=
os
.
path
.
join
(
doc_data_path
,
'img'
)
write_zip_file
(
img_save_path
,
os
.
path
.
join
(
doc_data_path
,
'{0}_img.zip'
.
format
(
doc_id_str
)))
shutil
.
rmtree
(
img_save_path
,
ignore_errors
=
True
)
#
img_save_path = os.path.join(doc_data_path, 'img')
#
write_zip_file(img_save_path, os.path.join(doc_data_path, '{0}_img.zip'.format(doc_id_str)))
#
shutil.rmtree(img_save_path, ignore_errors=True)
pdf_path
=
os
.
path
.
join
(
doc_data_path
,
'{0}.pdf'
.
format
(
doc_id_str
))
os
.
remove
(
pdf_path
)
self
.
online_log
.
info
(
'{0} [pdf & img removed] [task={1}]'
.
format
(
self
.
log_base
,
task_str
))
...
...
src/apps/doc/models.py
View file @
35db299
...
...
@@ -546,7 +546,7 @@ class AFCSECompareResult(models.Model):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
version
=
models
.
CharField
(
max_length
=
8
,
verbose_name
=
"POS/CMS version"
)
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"
是否完成
"
)
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"
整体结果
"
)
compare_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对字段总数"
)
failed_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对失败数目"
)
reason1_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因1数目"
)
...
...
@@ -574,7 +574,7 @@ class AFCCACompareResult(models.Model):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
version
=
models
.
CharField
(
max_length
=
8
,
verbose_name
=
"POS/CMS version"
)
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"
是否完成
"
)
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"
整体结果
"
)
compare_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对字段总数"
)
failed_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对失败数目"
)
reason1_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因1数目"
)
...
...
@@ -602,7 +602,7 @@ class HILSECompareResult(models.Model):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
version
=
models
.
CharField
(
max_length
=
8
,
verbose_name
=
"POS/CMS version"
)
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"
是否完成
"
)
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"
整体结果
"
)
compare_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对字段总数"
)
failed_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对失败数目"
)
reason1_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因1数目"
)
...
...
@@ -629,7 +629,7 @@ class HILCACompareResult(models.Model):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
version
=
models
.
CharField
(
max_length
=
8
,
verbose_name
=
"POS/CMS version"
)
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"
是否完成
"
)
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"
整体结果
"
)
compare_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对字段总数"
)
failed_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对失败数目"
)
reason1_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因1数目"
)
...
...
@@ -652,3 +652,103 @@ class HILCACompareResult(models.Model):
db_table
=
'hil_ca_compare_result'
class
AFCSECompareResultRecord
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"整体结果"
)
compare_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对字段总数"
)
failed_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对失败数目"
)
reason1_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因1数目"
)
reason2_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因2数目"
)
reason3_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因3数目"
)
reason4_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因4数目"
)
reason5_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因5数目"
)
reason6_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因6数目"
)
reason7_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因7数目"
)
reason8_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因8数目"
)
reason9_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因9数目"
)
reason10_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因10数目"
)
result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"比对结果"
)
comments
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"备注"
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'afc_se_compare_result_record'
class
AFCCACompareResultRecord
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"整体结果"
)
compare_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对字段总数"
)
failed_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对失败数目"
)
reason1_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因1数目"
)
reason2_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因2数目"
)
reason3_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因3数目"
)
reason4_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因4数目"
)
reason5_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因5数目"
)
reason6_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因6数目"
)
reason7_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因7数目"
)
reason8_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因8数目"
)
reason9_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因9数目"
)
reason10_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因10数目"
)
result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"比对结果"
)
comments
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"备注"
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'afc_ca_compare_result_record'
class
HILSECompareResultRecord
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"整体结果"
)
compare_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对字段总数"
)
failed_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对失败数目"
)
reason1_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因1数目"
)
reason2_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因2数目"
)
reason3_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因3数目"
)
reason4_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因4数目"
)
reason5_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因5数目"
)
reason6_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因6数目"
)
reason7_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因7数目"
)
reason8_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因8数目"
)
reason9_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因9数目"
)
reason10_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因10数目"
)
result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"比对结果"
)
comments
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"备注"
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'hil_se_compare_result_record'
class
HILCACompareResultRecord
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
is_finish
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"整体结果"
)
compare_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对字段总数"
)
failed_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"比对失败数目"
)
reason1_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因1数目"
)
reason2_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因2数目"
)
reason3_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因3数目"
)
reason4_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因4数目"
)
reason5_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因5数目"
)
reason6_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因6数目"
)
reason7_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因7数目"
)
reason8_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因8数目"
)
reason9_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因9数目"
)
reason10_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"原因10数目"
)
result
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"比对结果"
)
comments
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"备注"
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
# 索引
class
Meta
:
managed
=
False
db_table
=
'hil_ca_compare_result_record'
...
...
src/apps/doc/views.py
View file @
35db299
...
...
@@ -30,6 +30,10 @@ from .models import (
AFCSECompareResult
,
HILCACompareResult
,
HILSECompareResult
,
AFCCACompareResultRecord
,
AFCSECompareResultRecord
,
HILCACompareResultRecord
,
HILSECompareResultRecord
,
)
from
.named_enum
import
ErrorType
from
.mixins
import
DocHandler
...
...
@@ -295,7 +299,6 @@ application_information = {
priority_doc_args
=
{
'APPLICATION_INFORMATION'
:
fields
.
Nested
(
application_information
,
required
=
True
)
}
compare_offline_args
=
{
...
...
@@ -313,6 +316,32 @@ compare_offline_args = {
'workflow_name'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
1024
)),
}
result_item_args
=
{
consts
.
HEAD_LIST
[
0
]:
fields
.
Str
(
required
=
True
),
consts
.
HEAD_LIST
[
1
]:
fields
.
Str
(
required
=
True
),
consts
.
HEAD_LIST
[
2
]:
fields
.
Str
(
required
=
True
),
consts
.
HEAD_LIST
[
3
]:
fields
.
Str
(
required
=
True
),
consts
.
HEAD_LIST
[
4
]:
fields
.
Str
(
required
=
True
),
consts
.
HEAD_LIST
[
5
]:
fields
.
Str
(
required
=
True
),
consts
.
HEAD_LIST
[
6
]:
fields
.
Str
(
required
=
True
),
consts
.
HEAD_LIST
[
7
]:
fields
.
Str
(
required
=
True
),
consts
.
HEAD_LIST
[
8
]:
fields
.
List
(
fields
.
Str
(),
required
=
True
),
consts
.
HEAD_LIST
[
9
]:
fields
.
Int
(
required
=
True
),
}
result_update_args
=
{
'id'
:
fields
.
Int
(
required
=
True
),
'application_id'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
64
)),
'entity'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
BUSINESS_TYPE_LIST
)),
'scheme'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
OneOf
(
consts
.
DOC_SCHEME_LIST
)),
'whole_result'
:
fields
.
Str
(
required
=
True
),
'version'
:
fields
.
Str
(
required
=
True
),
'source'
:
fields
.
Str
(
required
=
True
),
'latest_compared_time'
:
fields
.
Str
(
required
=
True
),
'comments'
:
fields
.
Str
(
required
=
True
),
'result'
:
fields
.
List
(
fields
.
Nested
(
result_item_args
),
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
)),
}
class
UploadDocView
(
GenericView
,
DocHandler
):
# permission_classes = []
...
...
@@ -776,7 +805,7 @@ class CompareResultView(GenericView):
if
result_obj
is
None
:
whole_result
=
''
else
:
whole_result
=
'Y'
if
result_obj
.
is_finish
else
'N'
whole_result
=
consts
.
RESULT_Y
if
result_obj
.
is_finish
else
consts
.
RESULT_N
if
result_obj
is
None
or
result_obj
.
comments
is
None
:
comments
=
''
...
...
@@ -786,6 +815,7 @@ class CompareResultView(GenericView):
compare_result
=
{
'id'
:
0
if
result_obj
is
None
else
result_obj
.
id
,
'application_id'
:
case_id
,
'entity'
:
entity
,
'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
.
update_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
),
...
...
@@ -831,40 +861,79 @@ class CompareResultView(GenericView):
# return HttpResponse(html)
# 比对结果更新
# @use_args(result_update_args, location='data')
def
post
(
self
,
request
):
tmp_flag
=
random
.
choice
([
0
,
1
])
if
tmp_flag
==
0
:
return
response
.
ok
()
@use_args
(
result_update_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
result_id
=
args
.
get
(
'id'
)
case_id
=
args
.
get
(
'application_id'
)
update_time
=
args
.
get
(
'latest_compared_time'
)
scheme
=
args
.
get
(
'scheme'
)
entity
=
args
.
get
(
'entity'
)
whole_result
=
args
.
get
(
'whole_result'
)
if
entity
==
consts
.
HIL_PREFIX
:
result_table
=
HILCACompareResult
if
scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]
else
HILSECompareResult
record_table
=
HILCACompareResultRecord
if
scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]
else
HILSECompareResultRecord
else
:
result_id
=
None
entity
=
"AFC"
scheme
=
'SE'
case_id
=
'CH-S1120929121'
result_table
=
AFCCACompareResult
if
scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]
else
AFCSECompareResult
record_table
=
AFCCACompareResultRecord
if
scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]
else
AFCSECompareResultRecord
if
entity
==
consts
.
HIL_PREFIX
:
result_table
=
HILCACompareResult
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
HILSECompareResult
else
:
result_table
=
AFCCACompareResult
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
AFCSECompareResult
if
result_id
is
not
None
:
result_obj
=
result_table
.
objects
.
filter
(
id
=
result_id
)
.
first
()
else
:
result_obj
=
result_table
.
objects
.
filter
(
application_id
=
case_id
)
.
first
()
if
result_id
is
not
None
:
result_obj
=
result_table
.
objects
.
filter
(
id
=
result_id
)
.
first
()
else
:
result_obj
=
result_table
.
objects
.
filter
(
application_id
=
case_id
)
.
first
()
if
result_obj
is
None
:
return
response
.
ok
()
if
result_obj
is
None
:
whole_result
=
''
else
:
whole_result
=
'Y'
if
result_obj
.
is_finish
else
'N'
result_str
=
json
.
dumps
(
args
.
get
(
'result'
,
[]))
is_finish
=
whole_result
==
consts
.
RESULT_Y
compare_count
=
0
failed_count
=
0
reason_dict
=
{}
for
result
in
args
.
get
(
'result'
,
[]):
compare_count
+=
1
if
result
.
get
(
consts
.
HEAD_LIST
[
6
])
==
consts
.
RESULT_N
:
failed_count
+=
1
error_type
=
result
.
get
(
consts
.
HEAD_LIST
[
-
1
],
''
)
if
error_type
in
reason_dict
:
reason_dict
[
error_type
]
=
reason_dict
[
error_type
]
+
1
else
:
reason_dict
[
error_type
]
=
1
record_table
.
objects
.
create
(
application_id
=
case_id
,
is_finish
=
is_finish
,
compare_count
=
compare_count
,
failed_count
=
failed_count
,
reason1_count
=
reason_dict
.
get
(
0
,
0
),
reason2_count
=
reason_dict
.
get
(
1
,
0
),
reason3_count
=
reason_dict
.
get
(
2
,
0
),
reason4_count
=
reason_dict
.
get
(
3
,
0
),
reason5_count
=
reason_dict
.
get
(
4
,
0
),
reason6_count
=
reason_dict
.
get
(
5
,
0
),
reason7_count
=
reason_dict
.
get
(
6
,
0
),
reason8_count
=
reason_dict
.
get
(
7
,
0
),
reason9_count
=
reason_dict
.
get
(
8
,
0
),
reason10_count
=
reason_dict
.
get
(
9
,
0
),
result
=
result_str
,
comments
=
args
.
get
(
'comments'
,
''
),
)
if
result_obj
is
None
or
result_obj
.
comments
is
None
:
comments
=
''
else
:
comments
=
result_obj
.
comments
if
update_time
==
result_obj
.
update_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
):
result_obj
.
result
=
result_str
result_obj
.
comments
=
args
.
get
(
'comments'
,
''
)
result_obj
.
update_time
=
result_obj
.
update_time
result_obj
.
save
()
return
response
.
ok
()
else
:
whole_result
=
consts
.
RESULT_Y
if
result_obj
.
is_finish
else
consts
.
RESULT_N
comments
=
''
if
result_obj
.
comments
is
None
else
comments
=
result_obj
.
comments
compare_result
=
{
'id'
:
0
if
result_obj
is
None
else
result_obj
.
id
,
'application_id'
:
case_id
,
'entity'
:
entity
,
'scheme'
:
consts
.
DOC_SCHEME_LIST
[
0
]
if
scheme
==
consts
.
COMPARE_DOC_SCHEME_LIST
[
0
]
else
consts
.
DOC_SCHEME_LIST
[
1
],
'whole_result'
:
whole_result
,
...
...
src/celery_compare/tasks.py
View file @
35db299
This diff is collapsed.
Click to expand it.
src/common/tools/comparison.py
View file @
35db299
...
...
@@ -155,9 +155,30 @@ class Comparison:
ocr_s
=
ocr_str
.
translate
(
self
.
TRANS
)
return
self
.
build_res
(
input_s
==
ocr_s
)
def
ca_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
:
if
ocr_str
.
strip
()
==
''
:
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
ca_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
or
'***'
in
ocr_str
or
'至今'
in
ocr_str
:
...
...
@@ -176,6 +197,24 @@ class Comparison:
input_str
=
input_str
.
replace
(
'-'
,
kwargs
.
get
(
'input_replace'
))
return
self
.
build_res
(
input_str
==
ocr_str
)
def
ca_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'
]:
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
...
...
@@ -220,6 +259,11 @@ class Comparison:
ocr_tmp
=
re
.
sub
(
self
.
re_obj
,
''
,
ocr_str
)
.
strip
()
return
self
.
build_res
(
input_tmp
==
ocr_tmp
)
def
ca_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
)
...
...
@@ -231,6 +275,17 @@ class Comparison:
else
:
return
res
def
ca_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
:
...
...
@@ -240,6 +295,15 @@ class Comparison:
compare_str
=
self
.
CSOTH
return
self
.
build_res
(
input_str
==
compare_str
)
def
ca_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
)
def
se_date_compare_2
(
self
,
input_str
,
ocr_str
,
**
kwargs
):
try
:
input_date
=
time
.
strptime
(
input_str
,
"
%
Y-
%
m-
%
d"
)
...
...
src/common/tools/mssql_script7.py
View file @
35db299
...
...
@@ -3,11 +3,123 @@ import pyodbc
hil_sql
=
"""
ALTER TABLE hil_ca_compare_result ADD version nvarchar(8), comments nvarchar(max);
ALTER TABLE hil_se_compare_result ADD version nvarchar(8), comments nvarchar(max);
create table hil_se_compare_result_record
(
id int identity primary key,
application_id nvarchar(64) not null,
is_finish bit default 0 not null,
compare_count smallint default 0 not null,
failed_count smallint default 0 not null,
reason1_count smallint default 0 not null,
reason2_count smallint default 0 not null,
reason3_count smallint default 0 not null,
reason4_count smallint default 0 not null,
reason5_count smallint default 0 not null,
reason6_count smallint default 0 not null,
reason7_count smallint default 0 not null,
reason8_count smallint default 0 not null,
reason9_count smallint default 0 not null,
reason10_count smallint default 0 not null,
result nvarchar(max),
comments nvarchar(max),
create_time datetime not null
);
create index hil_se_compare_result_record_application_id_index
on hil_se_compare_result_record (application_id);
create index hil_se_compare_result_record_create_time_index
on hil_se_compare_result_record (create_time);
create table hil_ca_compare_result_record
(
id int identity primary key,
application_id nvarchar(64) not null,
is_finish bit default 0 not null,
compare_count smallint default 0 not null,
failed_count smallint default 0 not null,
reason1_count smallint default 0 not null,
reason2_count smallint default 0 not null,
reason3_count smallint default 0 not null,
reason4_count smallint default 0 not null,
reason5_count smallint default 0 not null,
reason6_count smallint default 0 not null,
reason7_count smallint default 0 not null,
reason8_count smallint default 0 not null,
reason9_count smallint default 0 not null,
reason10_count smallint default 0 not null,
result nvarchar(max),
comments nvarchar(max),
create_time datetime not null
);
create index hil_ca_compare_result_record_application_id_index
on hil_ca_compare_result_record (application_id);
create index hil_ca_compare_result_record_create_time_index
on hil_ca_compare_result_record (create_time);
"""
afc_sql
=
"""
ALTER TABLE afc_ca_compare_result ADD version nvarchar(8), comments nvarchar(max);
ALTER TABLE afc_se_compare_result ADD version nvarchar(8), comments nvarchar(max);
create table afc_se_compare_result_record
(
id int identity primary key,
application_id nvarchar(64) not null,
is_finish bit default 0 not null,
compare_count smallint default 0 not null,
failed_count smallint default 0 not null,
reason1_count smallint default 0 not null,
reason2_count smallint default 0 not null,
reason3_count smallint default 0 not null,
reason4_count smallint default 0 not null,
reason5_count smallint default 0 not null,
reason6_count smallint default 0 not null,
reason7_count smallint default 0 not null,
reason8_count smallint default 0 not null,
reason9_count smallint default 0 not null,
reason10_count smallint default 0 not null,
result nvarchar(max),
comments nvarchar(max),
create_time datetime not null
);
create index afc_se_compare_result_record_application_id_index
on afc_se_compare_result_record (application_id);
create index afc_se_compare_result_record_create_time_index
on afc_se_compare_result_record (create_time);
create table afc_ca_compare_result_record
(
id int identity primary key,
application_id nvarchar(64) not null,
is_finish bit default 0 not null,
compare_count smallint default 0 not null,
failed_count smallint default 0 not null,
reason1_count smallint default 0 not null,
reason2_count smallint default 0 not null,
reason3_count smallint default 0 not null,
reason4_count smallint default 0 not null,
reason5_count smallint default 0 not null,
reason6_count smallint default 0 not null,
reason7_count smallint default 0 not null,
reason8_count smallint default 0 not null,
reason9_count smallint default 0 not null,
reason10_count smallint default 0 not null,
result nvarchar(max),
comments nvarchar(max),
create_time datetime not null
);
create index afc_ca_compare_result_record_application_id_index
on afc_ca_compare_result_record (application_id);
create index afc_ca_compare_result_record_create_time_index
on afc_ca_compare_result_record (create_time);
"""
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
...
...
src/settings/conf/prd.ini
View file @
35db299
...
...
@@ -12,3 +12,5 @@ EDMS_DOWNLOAD_URL = http://sccn0639.bmwgroup.net/FH/FileHold/DocumentRepository/
EDMS_UPLOAD_URL
=
http://sccn0639.bmwgroup.net/FH/FileHold/DocumentRepository/UploadHandler.ashx
DEALER_CODE
=
ocr_group
BASE_URL
=
https://li19dkocruat02vm.bmwgroup.net
...
...
src/settings/conf/sit.ini
View file @
35db299
...
...
@@ -10,4 +10,6 @@ IMG_QUEUE_SIZE = 500
EDMS_DOWNLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/DownloadHandler.ashx
EDMS_UPLOAD_URL
=
https://edms-test.bmw.com/FH/FileHold/DocumentRepository/UploadHandler.ashx
DEALER_CODE
=
ocr_situ_group
\ No newline at end of file
DEALER_CODE
=
ocr_situ_group
BASE_URL
=
https://staging-bmw-ocr.situdata.com
\ No newline at end of file
...
...
src/settings/conf/uat.ini
View file @
35db299
...
...
@@ -10,4 +10,6 @@ IMG_QUEUE_SIZE = 500
EDMS_DOWNLOAD_URL
=
http://sccn0637.bmwgroup.net/FH/FileHold/DocumentRepository/DownloadHandler.ashx
EDMS_UPLOAD_URL
=
http://sccn0637.bmwgroup.net/FH/FileHold/DocumentRepository/UploadHandler.ashx
DEALER_CODE
=
ocr_situ_group
\ No newline at end of file
DEALER_CODE
=
ocr_situ_group
BASE_URL
=
https://li19dkocruat01vm.bmwgroup.net
\ No newline at end of file
...
...
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