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
beebba6a
authored
2021-07-07 17:49:45 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
se compare part 1
1 parent
3f50c8c2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
142 additions
and
9 deletions
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/mssql_script6.py
src/apps/doc/management/commands/ocr_process.py
View file @
beebba6
...
...
@@ -23,7 +23,20 @@ from apps.doc.ocr.edms import EDMS, rh
from
apps.doc.named_enum
import
KeywordsType
,
FailureReason
,
WorkflowName
,
ProcessName
,
RequestTeam
,
RequestTrigger
from
apps.doc.exceptions
import
EDMSException
,
OCR1Exception
,
OCR2Exception
,
OCR4Exception
from
apps.doc.ocr.wb
import
BSWorkbook
from
apps.doc.models
import
DocStatus
,
HILDoc
,
AFCDoc
,
Keywords
,
HILOCRResult
,
AFCOCRResult
,
HILOCRReport
,
AFCOCRReport
,
DDARecords
,
IDBCRecords
from
apps.doc.models
import
(
DocStatus
,
HILDoc
,
AFCDoc
,
Keywords
,
HILOCRResult
,
AFCOCRResult
,
AFCSEOCRResult
,
HILOCRReport
,
HILSEOCRResult
,
AFCOCRReport
,
DDARecords
,
IDBCRecords
)
from
celery_compare.tasks
import
compare
...
...
@@ -967,15 +980,21 @@ class Command(BaseCommand, LoggerMixin):
# TODO 识别结果存一张表,方便跑报表
# CA比对
if
doc
.
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]:
if
len
(
license_summary
)
>
0
and
doc
.
document_scheme
!=
consts
.
DOC_SCHEME_LIST
[
2
]:
try
:
is_ca
=
True
if
doc
.
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]
else
False
# 更新OCR累计识别结果表
result_class
=
HILOCRResult
if
business_type
==
consts
.
HIL_PREFIX
else
AFCOCRResult
if
business_type
==
consts
.
HIL_PREFIX
:
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
...
...
@@ -985,8 +1004,6 @@ class Command(BaseCommand, LoggerMixin):
elif
classify
==
consts
.
RP_CLASSIFY
and
rp_merge
:
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
if
not
hasattr
(
res_obj
,
field
):
continue
old_res_str
=
getattr
(
res_obj
,
field
)
if
old_res_str
is
None
:
last_res_str
=
json
.
dumps
(
license_list
)
...
...
@@ -1006,8 +1023,8 @@ class Command(BaseCommand, LoggerMixin):
# 触发比对
try
:
# pass
compare
.
apply_async
((
doc
.
application_id
,
business_type
,
None
,
res_obj
.
id
)
,
queue
=
'queue_compare'
)
compare
.
apply_async
((
doc
.
application_id
,
business_type
,
None
,
res_obj
.
id
,
is_ca
),
queue
=
'queue_compare'
)
except
Exception
as
e
:
self
.
online_log
.
error
(
'{0} [process error (comparison info send)] [task={1}] [error={2}]'
.
format
(
...
...
src/apps/doc/models.py
View file @
beebba6
...
...
@@ -268,6 +268,59 @@ class HILOCRResult(models.Model):
db_table
=
'hil_ocr_result'
# OCR结果累计表
class
AFCSEOCRResult
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
bs_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"银行流水"
)
mvi_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"机动车销售统一发票"
)
ic_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"身份证"
)
rp_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"居住证"
)
bc_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"银行卡"
)
bl_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"营业执照"
)
uci_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"二手车发票"
)
eep_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"港澳台通行证"
)
dl_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"行驶证"
)
pp_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"护照"
)
mvc_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"机动车登记证"
)
vat_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"增值税发票"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'afc_se_ocr_result'
situ_db_label
=
'afc'
# OCR结果累计表
class
HILSEOCRResult
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
bs_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"银行流水"
)
mvi_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"机动车销售统一发票"
)
ic_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"身份证"
)
rp_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"居住证"
)
bc_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"银行卡"
)
bl_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"营业执照"
)
uci_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"二手车发票"
)
eep_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"港澳台通行证"
)
dl_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"行驶证"
)
pp_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"护照"
)
mvc_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"机动车登记证"
)
vat_ocr
=
models
.
TextField
(
null
=
True
,
verbose_name
=
"增值税发票"
)
update_time
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'修改时间'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'hil_se_ocr_result'
# OCR Report
class
HILOCRReport
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
...
...
src/apps/doc/views.py
View file @
beebba6
...
...
@@ -474,7 +474,8 @@ class CompareView(GenericView):
corporate_cus_info
=
corporate_cus_info
,
)
# 触发比对
compare
.
apply_async
((
application_id
,
business_type
,
uniq_seq
,
None
),
queue
=
'queue_compare'
)
compare
.
apply_async
((
application_id
,
business_type
,
uniq_seq
,
None
,
True
),
queue
=
'queue_compare'
)
return
response
.
ok
()
post
.
openapi_doc
=
'''
...
...
src/celery_compare/tasks.py
View file @
beebba6
...
...
@@ -150,7 +150,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s
@app.task
def
compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
):
def
compare
(
application_id
,
application_entity
,
uniq_seq
,
ocr_res_id
,
is_ca
=
True
):
# POS: application_id, application_entity, uniq_seq, None
# OCR: application_id, business_type(application_entity), None, ocr_res_id
...
...
src/common/tools/mssql_script6.py
0 → 100644
View file @
beebba6
import
pyodbc
hil_sql
=
"""
create table hil_se_ocr_result
(
id int identity primary key,
application_id nvarchar(64) not null,
bs_ocr nvarchar(max),
mvi_ocr nvarchar(max),
ic_ocr nvarchar(max),
rp_ocr nvarchar(max),
bc_ocr nvarchar(max),
bl_ocr nvarchar(max),
uci_ocr nvarchar(max),
eep_ocr nvarchar(max),
dl_ocr nvarchar(max),
pp_ocr nvarchar(max),
mvc_ocr nvarchar(max),
vat_ocr nvarchar(max),
update_time datetime not null,
create_time datetime not null
);
create unique index hil_se_ocr_result_application_id_uindex
on hil_se_ocr_result (application_id);
"""
afc_sql
=
"""
create table afc_se_ocr_result
(
id int identity primary key,
application_id nvarchar(64) not null,
bs_ocr nvarchar(max),
mvi_ocr nvarchar(max),
ic_ocr nvarchar(max),
rp_ocr nvarchar(max),
bc_ocr nvarchar(max),
bl_ocr nvarchar(max),
uci_ocr nvarchar(max),
eep_ocr nvarchar(max),
dl_ocr nvarchar(max),
pp_ocr nvarchar(max),
mvc_ocr nvarchar(max),
vat_ocr nvarchar(max),
update_time datetime not null,
create_time datetime not null
);
create unique index afc_se_ocr_result_application_id_uindex
on afc_se_ocr_result (application_id);
"""
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
hil_cursor
=
hil_cnxn
.
cursor
()
hil_cursor
.
execute
(
hil_sql
)
hil_cursor
.
close
()
hil_cnxn
.
close
()
afc_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
afc_cursor
=
afc_cnxn
.
cursor
()
afc_cursor
.
execute
(
afc_sql
)
afc_cursor
.
close
()
afc_cnxn
.
close
()
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