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
9033711e
authored
2024-01-30 14:30:26 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'feature/CHINARPA-4357' into feature/uat-tmp
2 parents
16eb116a
5218f898
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
35 deletions
src/apps/doc/consts.py
src/apps/doc/management/commands/folder_ocr_process.py
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/consts.py
View file @
9033711
...
...
@@ -1412,9 +1412,9 @@ LEGAL_REP_NAME = '经营者姓名'
TCCOR
=
[
(
'customerChineseName'
,
'企业名称'
,
'company_compare'
,
{},
'customerChinessNameResult'
),
(
'legalRepName'
,
'经营者姓名'
,
'name_compare'
,
{},
'legalRepNameResult'
),
(
'idNum'
,
'
注册号
'
,
'common_compare'
,
{},
'idNumResult'
),
(
'businessLicenseNo'
,
'
注册号
'
,
'common_compare'
,
{},
'businessLicenseNoResult'
),
(
'taxRegistrationCode'
,
'
注册号
'
,
'common_compare'
,
{},
'taxRegistrationCodeResult'
),
(
'idNum'
,
'
统一社会信用代码
'
,
'common_compare'
,
{},
'idNumResult'
),
(
'businessLicenseNo'
,
'
统一社会信用代码
'
,
'common_compare'
,
{},
'businessLicenseNoResult'
),
(
'taxRegistrationCode'
,
'
统一社会信用代码
'
,
'common_compare'
,
{},
'taxRegistrationCodeResult'
),
(
'incorporationDate'
,
'成立日期'
,
'date_compare'
,
{
'ocr_replace'
:
True
},
'incorporationDateResult'
),
# 2017年07月11日
# 2017年07月11日至长期 1. OCR识别为长期,向GCAP发送:2099-12-31 00:00:00.0
(
'businessLicenseDueDate'
,
'营业期限'
,
'date_compare'
,
{
'ocr_split'
:
True
,
'long'
:
True
,
'ocr_replace'
:
True
},
'businessLicenseDueDateResult'
),
...
...
@@ -1862,10 +1862,10 @@ RP_COMPARE_LOGIC = {
BL_COMPARE_LOGIC
=
{
'companyName'
:
(
'企业名称'
,
'se_company_compare'
,
{},
'营业执照公司名称与系统不一致'
),
'legalRepName'
:
(
'经营者姓名'
,
'se_name_compare'
,
{},
'营业执照法定代表人与系统不一致'
),
'firstIdNo'
:
(
'
注册号
'
,
'se_common_compare'
,
{},
'营业执照统一社会信用代码与系统不一致'
),
'businessLicenseNo'
:
(
'
注册号
'
,
'se_common_compare'
,
{},
'营业执照统一社会信用代码与系统不一致'
),
'organizationCreditCode'
:
(
'
注册号
'
,
'se_common_compare'
,
{},
'营业执照统一社会信用代码与系统不一致'
),
'taxRegistrationCertificateNo'
:
(
'
注册号
'
,
'se_common_compare'
,
{},
'营业执照统一社会信用代码与系统不一致'
),
'firstIdNo'
:
(
'
统一社会信用代码
'
,
'se_common_compare'
,
{},
'营业执照统一社会信用代码与系统不一致'
),
'businessLicenseNo'
:
(
'
统一社会信用代码
'
,
'se_common_compare'
,
{},
'营业执照统一社会信用代码与系统不一致'
),
'organizationCreditCode'
:
(
'
统一社会信用代码
'
,
'se_common_compare'
,
{},
'营业执照统一社会信用代码与系统不一致'
),
'taxRegistrationCertificateNo'
:
(
'
统一社会信用代码
'
,
'se_common_compare'
,
{},
'营业执照统一社会信用代码与系统不一致'
),
'establishmentDate'
:
(
'成立日期'
,
'se_date_compare'
,
{
'ocr_replace'
:
True
,
'two_year'
:
True
},
'营业执照显示公司成立不满足2年'
),
'businessLicenseDueDate'
:
(
'营业期限'
,
'se_date_compare'
,
{
'ocr_split'
:
True
,
'long'
:
True
,
'ocr_replace'
:
True
,
'today'
:
True
},
'公司营业期限疑似过期'
),
'organizationType'
:
(
'企业类型'
,
'se_type_compare'
,
{},
'营业执照企业类型与系统不一致'
),
...
...
@@ -2306,9 +2306,9 @@ CA_RP_COMPARE_LOGIC = {
CA_BL_COMPARE_LOGIC
=
{
'companyName'
:
(
'企业名称'
,
'ca_company_compare'
,
{}),
'customerChineseName'
:
(
'经营者姓名'
,
'ca_name_compare'
,
{}),
'idNum'
:
(
'
注册号
'
,
'ca_common_compare'
,
{}),
'businessLicenseNo'
:
(
'
注册号
'
,
'ca_common_compare'
,
{}),
'taxRegistrationCode'
:
(
'
注册号
'
,
'ca_common_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'
,
{}),
...
...
src/apps/doc/management/commands/folder_ocr_process.py
View file @
9033711
...
...
@@ -340,6 +340,7 @@ class Command(BaseCommand, LoggerMixin):
if
len
(
true_file_set
)
==
0
and
len
(
os_error_filename_set
)
>
0
:
true_file_set
.
add
(
os_error_filename_set
.
pop
())
for
name
in
true_file_set
:
time
.
sleep
(
8
)
is_success
=
True
failure_reason
=
OfflineFailureReason
.
OS_ERROR
.
value
start_time
=
time
.
time
()
...
...
src/apps/doc/management/commands/ocr_process.py
View file @
9033711
...
...
@@ -10,6 +10,7 @@ import traceback
from
collections
import
Counter
from
datetime
import
datetime
,
date
from
django
import
db
from
django.db
import
transaction
from
django.utils
import
timezone
from
django.core.management
import
BaseCommand
from
multiprocessing
import
Process
,
Queue
,
Manager
,
Lock
...
...
@@ -2034,31 +2035,34 @@ class Command(BaseCommand, LoggerMixin):
result_class
=
HILOCRResult
if
is_ca
else
HILSEOCRResult
else
:
result_class
=
AFCOCRResult
if
is_ca
else
AFCSEOCRResult
res_obj
=
result_class
.
objects
.
filter
(
application_id
=
doc
.
application_id
)
.
first
()
if
res_obj
is
None
:
res_obj
=
result_class
()
res_obj
.
application_id
=
doc
.
application_id
for
classify
,
field
in
consts
.
RESULT_MAPPING
.
items
():
if
not
hasattr
(
res_obj
,
field
):
continue
license_list
=
license_summary
.
get
(
classify
)
if
not
license_list
:
continue
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
:
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
old_res_str
=
getattr
(
res_obj
,
field
)
if
old_res_str
is
None
:
last_res_str
=
json
.
dumps
(
license_list
)
else
:
old_res_list
=
json
.
loads
(
old_res_str
)
old_res_list
.
extend
(
license_list
)
last_res_str
=
json
.
dumps
(
old_res_list
)
setattr
(
res_obj
,
field
,
last_res_str
)
res_obj
.
save
()
res_obj
=
result_class
.
objects
.
select_for_update
()
.
filter
(
application_id
=
doc
.
application_id
)
.
first
()
with
transaction
.
atomic
():
self
.
online_log
.
info
(
'{0} [sql lock application_id={1}]'
.
format
(
self
.
log_base
,
doc
.
application_id
))
if
res_obj
is
None
:
res_obj
=
result_class
()
res_obj
.
application_id
=
doc
.
application_id
for
classify
,
field
in
consts
.
RESULT_MAPPING
.
items
():
if
not
hasattr
(
res_obj
,
field
):
continue
license_list
=
license_summary
.
get
(
classify
)
if
not
license_list
:
continue
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
:
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
old_res_str
=
getattr
(
res_obj
,
field
)
if
old_res_str
is
None
:
last_res_str
=
json
.
dumps
(
license_list
)
else
:
old_res_list
=
json
.
loads
(
old_res_str
)
old_res_list
.
extend
(
license_list
)
last_res_str
=
json
.
dumps
(
old_res_list
)
setattr
(
res_obj
,
field
,
last_res_str
)
res_obj
.
save
()
self
.
online_log
.
info
(
'{0} [sql lock release application_id={1}]'
.
format
(
self
.
log_base
,
doc
.
application_id
))
except
Exception
as
e
:
self
.
online_log
.
error
(
'{0} [process error (ocr result save)] [task={1}] [error={2}]'
.
format
(
...
...
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