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
db4b72a2
authored
2022-10-18 15:03:26 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
report fix
1 parent
4215bbbf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
24 deletions
src/apps/doc/management/commands/folder_dda_process.py
src/apps/doc/management/commands/folder_ltgt_process.py
src/apps/doc/management/commands/folder_ocr_process.py
src/apps/doc/management/commands/folder_wsc_process.py
src/apps/doc/models.py
src/common/tools/mssql_script20.py
src/apps/doc/management/commands/folder_dda_process.py
View file @
db4b72a
...
...
@@ -20,7 +20,7 @@ from common.tools.pdf_to_img import PDFHandler
from
apps.doc
import
consts
from
apps.doc.exceptions
import
OCR1Exception
,
OCR2Exception
,
LTGTException
from
apps.doc.ocr.wb
import
BSWorkbook
from
apps.doc.models
import
OfflineReport
from
apps.doc.models
import
OfflineReport
,
AFCOfflineReport
from
apps.doc.named_enum
import
OfflineFailureReason
...
...
@@ -447,7 +447,8 @@ class Command(BaseCommand, LoggerMixin):
finally
:
end_time
=
time
.
time
()
try
:
OfflineReport
.
objects
.
create
(
report_table
=
OfflineReport
if
input_dir
.
find
(
consts
.
HIL_PREFIX
)
!=
-
1
else
AFCOfflineReport
report_table
.
objects
.
create
(
input_folder
=
input_dir
,
doc_type
=
consts
.
DDA_CLASSIFY
,
file_name
=
name
,
...
...
src/apps/doc/management/commands/folder_ltgt_process.py
View file @
db4b72a
...
...
@@ -21,7 +21,7 @@ from common.electronic_afc_contract.afc_contract_ocr import predict as afc_predi
from
apps.doc
import
consts
from
apps.doc.exceptions
import
OCR1Exception
,
OCR2Exception
,
LTGTException
from
apps.doc.ocr.wb
import
BSWorkbook
from
apps.doc.models
import
OfflineReport
from
apps.doc.models
import
OfflineReport
,
AFCOfflineReport
from
apps.doc.named_enum
import
OfflineFailureReason
...
...
@@ -769,7 +769,8 @@ class Command(BaseCommand, LoggerMixin):
finally
:
end_time
=
time
.
time
()
try
:
OfflineReport
.
objects
.
create
(
report_table
=
OfflineReport
if
input_dir
.
find
(
consts
.
HIL_PREFIX
)
!=
-
1
else
AFCOfflineReport
report_table
.
objects
.
create
(
input_folder
=
input_dir
,
doc_type
=
classify
,
file_name
=
name
,
...
...
src/apps/doc/management/commands/folder_ocr_process.py
View file @
db4b72a
...
...
@@ -18,7 +18,7 @@ from common.tools.pdf_to_img import PDFHandler
from
apps.doc
import
consts
from
apps.doc.exceptions
import
OCR1Exception
,
OCR4Exception
from
apps.doc.ocr.wb
import
BSWorkbook
from
apps.doc.models
import
OfflineReport
from
apps.doc.models
import
OfflineReport
,
AFCOfflineReport
from
apps.doc.named_enum
import
OfflineFailureReason
...
...
@@ -385,7 +385,8 @@ class Command(BaseCommand, LoggerMixin):
finally
:
end_time
=
time
.
time
()
try
:
OfflineReport
.
objects
.
create
(
report_table
=
OfflineReport
if
input_dir
.
find
(
consts
.
HIL_PREFIX
)
!=
-
1
else
AFCOfflineReport
report_table
.
objects
.
create
(
input_folder
=
input_dir
,
doc_type
=
classify
,
file_name
=
name
,
...
...
src/apps/doc/management/commands/folder_wsc_process.py
View file @
db4b72a
...
...
@@ -21,7 +21,7 @@ from common.tools.pdf_to_img import PDFHandler
from
apps.doc
import
consts
from
apps.doc.exceptions
import
OCR1Exception
,
OCR4Exception
from
apps.doc.ocr.wb
import
BSWorkbook
,
PatternFill
from
apps.doc.models
import
OfflineReport
from
apps.doc.models
import
OfflineReport
,
AFCOfflineReport
from
apps.doc.named_enum
import
OfflineFailureReason
...
...
@@ -632,7 +632,8 @@ class Command(BaseCommand, LoggerMixin):
finally
:
end_time
=
time
.
time
()
try
:
OfflineReport
.
objects
.
create
(
report_table
=
OfflineReport
if
input_dir
.
find
(
consts
.
HIL_PREFIX
)
!=
-
1
else
AFCOfflineReport
report_table
.
objects
.
create
(
input_folder
=
input_dir
,
doc_type
=
consts
.
FOLDER_WSC_CLASSIFY
,
file_name
=
name
,
...
...
src/apps/doc/models.py
View file @
db4b72a
...
...
@@ -923,6 +923,7 @@ class MposReport(models.Model):
image_count
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"图片数目"
)
# status = models.SmallIntegerField(default=, verbose_name="请求状态")
status
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否成功"
)
source
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"来源"
)
# 默认0,代表MPOS
duration
=
models
.
IntegerField
(
null
=
True
,
verbose_name
=
'处理时长'
)
...
...
@@ -950,20 +951,20 @@ class OfflineReport(models.Model):
db_table
=
'offline_report'
#
class AFCOfflineReport(models.Model):
#
id = models.AutoField(primary_key=True, verbose_name="id") # 主键
#
#
input_folder = models.CharField(max_length=512, verbose_name="文件夹路径")
#
doc_type = models.SmallIntegerField(default=0, verbose_name="文件类型")
#
file_name = models.CharField(max_length=1024, verbose_name="文件名")
#
status = models.BooleanField(default=True, verbose_name="是否成功")
#
failure_reason = models.SmallIntegerField(default=0, verbose_name="失败原因")
#
duration = models.IntegerField(verbose_name='处理时长')
#
#
create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
#
#
class Meta:
#
managed = False
#
db_table = 'afc_offline_report'
#
situ_db_label = 'afc'
class
AFCOfflineReport
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
input_folder
=
models
.
CharField
(
max_length
=
512
,
verbose_name
=
"文件夹路径"
)
doc_type
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"文件类型"
)
file_name
=
models
.
CharField
(
max_length
=
1024
,
verbose_name
=
"文件名"
)
status
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否成功"
)
failure_reason
=
models
.
SmallIntegerField
(
default
=
0
,
verbose_name
=
"失败原因"
)
duration
=
models
.
IntegerField
(
verbose_name
=
'处理时长'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'afc_offline_report'
situ_db_label
=
'afc'
...
...
src/common/tools/mssql_script20.py
0 → 100644
View file @
db4b72a
import
pyodbc
hil_sql
=
"""
ALTER TABLE mpos_report ADD source tinyint default 0 not null;
"""
afc_sql
=
"""
create table afc_offline_report
(
id bigint identity primary key,
input_folder nvarchar(512) not null,
doc_type tinyint default 0 not null,
file_name nvarchar(1024) not null,
status bit default 1 not null,
failure_reason tinyint default 0 not null,
duration smallint not null,
create_time datetime not null
);
"""
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