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
c7852512
authored
2022-09-13 17:02:53 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update bs report
1 parent
9e45e68d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
23 deletions
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/models.py
src/apps/doc/named_enum.py
src/apps/doc/ocr/wb.py
src/common/tools/mssql_script19.py
src/apps/doc/management/commands/ocr_process.py
View file @
c785251
...
...
@@ -23,7 +23,7 @@ from common.electronic_hil_contract.hil_contract_ocr import predict as hil_predi
from
apps.doc
import
consts
# from apps.doc.ocr.edms import EDMS, rh
from
apps.doc.ocr.ecm
import
ECM
,
rh
from
apps.doc.named_enum
import
KeywordsType
,
FailureReason
,
WorkflowName
,
ProcessName
,
RequestTeam
,
RequestTrigger
from
apps.doc.named_enum
import
KeywordsType
,
FailureReason
,
WorkflowName
,
ProcessName
,
RequestTeam
,
RequestTrigger
,
BSCheckResult
from
apps.doc.exceptions
import
EDMSException
,
OCR1Exception
,
OCR2Exception
,
OCR4Exception
from
apps.doc.ocr.wb
import
BSWorkbook
from
apps.doc.models
import
(
...
...
@@ -944,7 +944,7 @@ class Command(BaseCommand, LoggerMixin):
'role'
:
bs_info
.
get
(
'role'
,
''
),
'print_time'
:
print_date
,
'timedelta'
:
bs_info
.
get
(
'timedelta'
,
''
),
'verify'
:
bs_info
.
get
(
'verify'
,
True
)
'verify'
:
bs_info
.
get
(
'verify
_res_ebank
'
,
True
)
}
)
return
res
...
...
@@ -1626,7 +1626,7 @@ class Command(BaseCommand, LoggerMixin):
# 'idcard': True or False,
# 'bs': None or normal or mobile,
# }
report_list
=
[
None
,
False
,
None
,
None
]
report_list
=
[
None
,
False
,
None
,
None
,
None
,
None
]
do_dda
=
is_hil
and
doc
.
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
1
]
except
Exception
as
e
:
self
.
online_log
.
error
(
'{0} [process error (db filter)] [task={1}] [error={2}]'
.
format
(
...
...
@@ -1815,6 +1815,15 @@ class Command(BaseCommand, LoggerMixin):
else
:
report_list
[
2
]
=
WorkflowName
.
NORMAL
.
value
bs_name_list
=
[]
for
tmp_classify
in
bs_classify_set
:
try
:
bs_name
=
consts
.
CLASSIFY_LIST
[
tmp_classify
][
0
]
except
Exception
as
e
:
bs_name
=
'Unknown'
bs_name_list
.
append
(
bs_name
)
report_list
[
4
]
=
'、'
.
join
(
bs_name_list
)
merged_bs_summary
=
self
.
rebuild_bs_summary
(
bs_summary
,
unknown_summary
)
del
unknown_summary
...
...
@@ -1901,6 +1910,40 @@ class Command(BaseCommand, LoggerMixin):
else
:
self
.
online_log
.
info
(
'{0} [process complete] [task={1}]'
.
format
(
self
.
log_base
,
task_str
))
os
.
remove
(
excel_path
)
# report新增流水真伪
try
:
check_false_classify
=
set
()
all_check_classify
=
set
()
if
isinstance
(
doc
.
metadata
,
str
):
verify_field
=
'verify_res_ebank'
else
:
verify_field
=
'verify_res_paper_bank'
for
bs_info
in
merged_bs_summary
.
values
():
all_check_classify
.
add
(
bs_info
[
'classify'
])
if
verify_field
not
in
bs_info
:
report_list
[
5
]
=
BSCheckResult
.
CHECK_FAILED
.
value
break
if
not
bs_info
[
verify_field
]:
check_false_classify
.
add
(
bs_info
[
'classify'
])
else
:
# 电子
if
isinstance
(
doc
.
metadata
,
str
):
if
len
(
check_false_classify
)
>
0
:
report_list
[
5
]
=
BSCheckResult
.
CHECK_FALSE
.
value
else
:
report_list
[
5
]
=
BSCheckResult
.
CHECK_TRUE
.
value
# 纸质
else
:
if
check_false_classify
&
consts
.
BS_VERIFY_CLASSIFY
:
report_list
[
5
]
=
BSCheckResult
.
CHECK_FALSE
.
value
elif
all_check_classify
&
consts
.
BS_VERIFY_CLASSIFY
:
report_list
[
5
]
=
BSCheckResult
.
CHECK_TRUE
.
value
else
:
report_list
[
5
]
=
BSCheckResult
.
NO_CHECK
.
value
except
Exception
as
e
:
report_list
[
5
]
=
BSCheckResult
.
CHECK_FAILED
.
value
finally
:
self
.
rebuild_contract
(
license_summary
,
contract_result_compare
)
...
...
@@ -2222,6 +2265,9 @@ class Command(BaseCommand, LoggerMixin):
try
:
if
report_list
[
2
]
is
not
None
:
is_ebank
=
True
if
isinstance
(
doc
.
metadata
,
str
)
else
False
bank_name
=
report_list
[
4
]
if
isinstance
(
report_list
[
4
],
str
)
else
'Unknown'
bs_check_result
=
report_list
[
5
]
if
isinstance
(
report_list
[
5
],
int
)
else
BSCheckResult
.
CHECK_FAILED
.
value
report_table
.
objects
.
create
(
case_number
=
doc
.
application_id
,
request_team
=
RequestTeam
.
get_value
(
doc
.
document_scheme
,
0
),
...
...
@@ -2231,6 +2277,9 @@ class Command(BaseCommand, LoggerMixin):
transaction_end
=
end_time
,
process_name
=
ProcessName
.
BS
.
value
,
workflow_name
=
report_list
[
2
],
bank_name
=
bank_name
,
is_ebank
=
is_ebank
,
bs_check_result
=
bs_check_result
,
)
except
Exception
as
e
:
self
.
online_log
.
error
(
'{0} [process error (report db save)] [error={1}]'
.
format
(
...
...
src/apps/doc/models.py
View file @
c785251
...
...
@@ -455,12 +455,9 @@ class HILOCRReport(models.Model):
workflow_name
=
models
.
SmallIntegerField
(
null
=
True
,
verbose_name
=
"工作流程"
)
notes
=
models
.
CharField
(
null
=
True
,
max_length
=
2048
,
verbose_name
=
"备注"
)
# 1. bank_name string eg. '农业银行-交易清单'
# 2. is_ebank boolean eg. 1
# 1. is_bs_check boolean eg. 1
# 2. bs_check_result int eg. 2(电子-author)
#
bank_name
=
models
.
CharField
(
null
=
True
,
max_length
=
2048
,
verbose_name
=
"版式名称"
)
is_ebank
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"是否电子"
)
bs_check_result
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"鉴伪结果"
)
# 0 无鉴伪 1鉴伪pass 2鉴伪nopass 3鉴伪过程异常
class
Meta
:
managed
=
False
...
...
@@ -482,6 +479,10 @@ class AFCOCRReport(models.Model):
workflow_name
=
models
.
SmallIntegerField
(
null
=
True
,
verbose_name
=
"工作流程"
)
notes
=
models
.
CharField
(
null
=
True
,
max_length
=
2048
,
verbose_name
=
"备注"
)
bank_name
=
models
.
CharField
(
null
=
True
,
max_length
=
2048
,
verbose_name
=
"版式名称"
)
is_ebank
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
"是否电子"
)
bs_check_result
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"鉴伪结果"
)
# 0 无鉴伪 1鉴伪pass 2鉴伪nopass
class
Meta
:
managed
=
False
db_table
=
'afc_ocr_report'
...
...
src/apps/doc/named_enum.py
View file @
c785251
...
...
@@ -83,3 +83,10 @@ class RPAResult(NamedEnum):
ERROR1
=
(
2
,
'business error'
)
ERROR2
=
(
3
,
'system error'
)
NULL
=
(
0
,
'null'
)
class
BSCheckResult
(
NamedEnum
):
NO_CHECK
=
(
0
,
'NO_CHECK'
)
CHECK_TRUE
=
(
1
,
'CHECK_TRUE'
)
CHECK_FALSE
=
(
2
,
'CHECK_FALSE'
)
CHECK_FAILED
=
(
3
,
'CHECK_FAILED'
)
...
...
src/apps/doc/ocr/wb.py
View file @
c785251
...
...
@@ -394,8 +394,9 @@ class BSWorkbook(Workbook):
cell
.
fill
=
self
.
amount_fill
# verify_res = False if len(metadata_highlight_row) > 0 or len(verify_highlight_row) > 0 else True
verify_res
=
False
if
len
(
metadata_highlight_row
)
>
0
else
True
return
ms
,
timedelta
,
verify_res
verify_res_ebank
=
False
if
len
(
metadata_highlight_row
)
>
0
else
True
verify_res_paper_bank
=
False
if
len
(
verify_highlight_row
)
>
0
else
True
return
ms
,
timedelta
,
verify_res_ebank
,
verify_res_paper_bank
@staticmethod
def
amount_format
(
amount_str
):
...
...
@@ -726,7 +727,7 @@ class BSWorkbook(Workbook):
# 2.元信息提取表
confidence
=
self
.
get_confidence
(
max_find_count
,
classify
)
is_verify_classify
=
classify
in
consts
.
BS_VERIFY_CLASSIFY
ms
,
timedelta
,
verify_res
=
self
.
build_meta_sheet
(
role_name
,
ms
,
timedelta
,
verify_res
_ebank
,
verify_res_paper_bank
=
self
.
build_meta_sheet
(
role_name
,
new_card
,
confidence
,
summary
.
get
(
'code'
),
...
...
@@ -740,7 +741,8 @@ class BSWorkbook(Workbook):
summary
[
'timedelta'
]
=
timedelta
summary
[
'end_date'
]
=
end_date
summary
[
'verify'
]
=
verify_res
summary
[
'verify_res_ebank'
]
=
verify_res_ebank
summary
[
'verify_res_paper_bank'
]
=
verify_res_paper_bank
# 3.创建月份表、提取/高亮关键行
# 倒序处理
...
...
src/common/tools/mssql_script19.py
View file @
c785251
...
...
@@ -10,11 +10,17 @@ hil_sql = """
duration smallint,
create_time datetime not null
);
ALTER TABLE hil_ocr_report ADD bank_name nvarchar(2048);
ALTER TABLE hil_ocr_report ADD is_ebank bit default 0 not null;
ALTER TABLE hil_ocr_report ADD bs_check_result tinyint default 0 not null;
"""
# afc_sql = """
#
# """
afc_sql
=
"""
ALTER TABLE afc_ocr_report ADD bank_name nvarchar(2048);
ALTER TABLE afc_ocr_report ADD is_ebank bit default 0 not null;
ALTER TABLE afc_ocr_report ADD bs_check_result tinyint default 0 not null;
"""
hil_cnxn
=
pyodbc
.
connect
(
'DRIVER={ODBC Driver 17 for SQL Server};'
,
autocommit
=
True
)
...
...
@@ -24,10 +30,10 @@ 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()
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