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
530a9a8c
authored
2022-10-18 16:23:53 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
report add go
1 parent
db4b72a2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
9 deletions
src/apps/doc/models.py
src/apps/doc/views.py
src/common/response.py
src/common/tools/mssql_script20.py
src/apps/doc/models.py
View file @
530a9a8
...
...
@@ -968,3 +968,13 @@ class AFCOfflineReport(models.Model):
db_table
=
'afc_offline_report'
situ_db_label
=
'afc'
class
GenericOCRReport
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
status
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
"是否成功"
)
duration
=
models
.
IntegerField
(
null
=
True
,
verbose_name
=
'处理时长'
)
create_time
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'创建时间'
)
class
Meta
:
managed
=
False
db_table
=
'generic_ocr_report'
...
...
src/apps/doc/views.py
View file @
530a9a8
...
...
@@ -46,6 +46,7 @@ from .models import (
HILbankVerification
,
AFCbankVerification
,
MposReport
,
GenericOCRReport
,
)
from
.named_enum
import
ErrorType
,
AutoResult
,
WholeResult
,
RPAResult
from
.mixins
import
DocHandler
,
MPOSHandler
...
...
@@ -1510,14 +1511,34 @@ class GoView(GenericView):
@use_args
(
go_args
,
location
=
'files'
)
def
post
(
self
,
request
,
args
):
files
=
[
(
'img'
,
(
'file'
,
args
.
get
(
'image'
),
'application/octet-stream'
))
]
go_result
=
requests
.
post
(
url
=
conf
.
GO_OCR_URL
,
files
=
files
)
result
=
None
is_success
=
False
start_time
=
time
.
time
()
try
:
files
=
[
(
'img'
,
(
'file'
,
args
.
get
(
'image'
),
'application/octet-stream'
))
]
if
go_result
.
status_code
==
200
:
result
=
go_result
.
json
()
.
get
(
'data'
,
''
)
return
response
.
ok
(
data
=
result
)
go_result
=
requests
.
post
(
url
=
conf
.
GO_OCR_URL
,
files
=
files
)
except
Exception
as
e
:
pass
else
:
return
response
.
res_content
(
3
,
'识别错误'
,
data
=
None
)
if
go_result
.
status_code
==
200
:
is_success
=
True
result
=
go_result
.
json
()
.
get
(
'data'
,
''
)
finally
:
end_time
=
time
.
time
()
duration_second
=
int
(
end_time
-
start_time
)
try
:
GenericOCRReport
.
objects
.
create
(
status
=
is_success
,
duration
=
duration_second
,
)
except
Exception
as
e
:
self
.
exception_log
.
exception
(
'[go view] [db save failed] [error={0}]'
.
format
(
traceback
.
format_exc
()))
if
is_success
:
return
response
.
ok
(
data
=
result
)
else
:
return
response
.
error_msg
(
msg
=
'识别错误'
)
...
...
src/common/response.py
View file @
530a9a8
...
...
@@ -35,6 +35,10 @@ def ok(**kwargs):
return
APIResponse
(
MetaStatus
.
SUCCESS
.
value
,
msg
=
MetaStatus
.
SUCCESS
.
verbose_name
,
**
kwargs
)
def
error_msg
(
msg
=
'internal error'
,
**
kwargs
):
return
APIResponse
(
MetaStatus
.
INTERNAL_ERROR
.
value
,
msg
=
msg
,
**
kwargs
)
def
need_update
(
**
kwargs
):
return
APIResponse
(
MetaStatus
.
NEED_UPDATE
.
value
,
msg
=
MetaStatus
.
NEED_UPDATE
.
verbose_name
,
**
kwargs
)
...
...
src/common/tools/mssql_script20.py
View file @
530a9a8
import
pyodbc
hil_sql
=
"""
create table generic_ocr_report
(
id bigint identity primary key,
status bit default 1 not null,
duration smallint,
create_time datetime not null
);
ALTER TABLE mpos_report ADD source tinyint default 0 not null;
"""
...
...
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