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
feecd311
authored
2022-11-04 19:29:32 +0800
by
王聪
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
pos 3045 update
1 parent
3690e26d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
3 deletions
requirements/base.txt
src/apps/doc/pos_urls.py
src/apps/urls.py
src/pos/views.py
requirements/base.txt
View file @
feecd31
...
...
@@ -18,16 +18,16 @@ idna==2.9
idna-ssl==1.1.0
isodate==0.6.0
jdcal==1.4.1
lxml==4.
5
.1
lxml==4.
9
.1
marshmallow==3.6.1
multidict==4.7.6
oauthlib==3.1.0
openpyxl==3.0.4
pdfminer3k==1.3.4
Pillow==
7.1.2
Pillow==
9.2.0
ply==3.11
PyJWT==1.7.1
PyMuPDF==1.
17.0
PyMuPDF==1.
20.2
PyMySQL==0.9.3
pytz==2020.1
redis==3.4.1
...
...
src/apps/doc/pos_urls.py
0 → 100644
View file @
feecd31
from
django.urls
import
path
from
pos
import
views
urlpatterns
=
[
path
(
r'nsc/invoice'
,
views
.
NSCInvoiceView
.
as_view
()),
path
(
r'de-mortgage'
,
views
.
DeMortgageView
.
as_view
()),
]
src/apps/urls.py
View file @
feecd31
...
...
@@ -26,6 +26,7 @@ urlpatterns = [
path
(
r'api/compare/'
,
include
(
'apps.doc.compare_urls'
)),
path
(
r'api/doc/'
,
include
(
'apps.doc.internal_urls'
)),
path
(
r'api/mpos/'
,
include
(
'apps.doc.mpos_urls'
)),
path
(
r'api/pos/'
,
include
(
'apps.doc.pos_urls'
)),
path
(
r'api/go/'
,
include
(
'apps.doc.go_urls'
)),
path
(
'api/oauth/'
,
include
(
'oauth2_provider.urls'
,
namespace
=
'oauth2_provider'
)),
]
...
...
src/pos/views.py
0 → 100644
View file @
feecd31
from
common.mixins
import
GenericView
from
webargs.djangoparser
import
use_args
,
parser
from
webargs
import
fields
,
validate
from
apps.doc.views
import
CustomDecimal
,
CustomDate
from
common
import
response
from
apps.doc.models
import
HILSEOCRResult
,
HILOCRResult
,
AFCSEOCRResult
,
AFCOCRResult
from
apps.doc
import
consts
params
=
{
'invoiceCode'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
128
)),
'invoiceNumber'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
64
)),
'issueDate'
:
CustomDate
(
required
=
True
),
'buyerName'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
64
)),
"buyerId"
:
fields
.
Int
(
required
=
True
),
'vin'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
128
)),
'dealer'
:
fields
.
Str
(
required
=
False
,
validate
=
validate
.
Length
(
max
=
64
)),
'priceWithVat'
:
CustomDecimal
(
required
=
False
),
'priceNoVat'
:
CustomDecimal
(
required
=
True
),
'priceInCapitals'
:
fields
.
Str
(
required
=
False
),
'vat'
:
CustomDecimal
(
required
=
True
),
'vatRate'
:
CustomDecimal
(
required
=
True
),
}
input_args
=
{
'content'
:
fields
.
Nested
(
params
,
required
=
True
)
}
# pos 接口接收NSC 发票信息
class
NSCInvoiceView
(
GenericView
):
@use_args
(
input_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
# interface_report mpos to ocr
content
=
args
.
get
(
'content'
,
{})
invoice_code
=
content
[
'invoiceCode'
]
invoice_number
=
content
[
'invoiceNumber'
]
issue_date
=
content
[
'issueDate'
]
buyer_name
=
content
[
'buyerName'
]
buyer_id
=
content
[
'buyerId'
]
vin
=
content
[
'vin'
]
dealer
=
content
[
'dealer'
]
price_with_vat
=
content
[
'priceWithVat'
]
price_no_vat
=
content
[
'priceNoVat'
]
price_in_capitals
=
content
[
'priceInCapitals'
]
vat
=
content
[
'vat'
]
vat_rate
=
content
[
'vatRate'
]
return
response
.
ok
(
data
=
content
)
de_mortgage_params
=
{
}
de_mortgage_args
=
{
'content'
:
fields
.
Nested
(
de_mortgage_params
,
required
=
True
)
}
# 解除抵押识别处理
class
DeMortgageView
(
GenericView
):
@use_args
(
de_mortgage_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
# interface_report mpos to ocr
content
=
args
.
get
(
'content'
,
{})
application_id
=
content
[
'applicationId'
]
customer_name
=
content
[
'customerName'
]
application_entity
=
content
[
'applicationEntity'
]
de_mortgage_date
=
content
[
'deMortgageDate'
]
# ocr 检测
# 根据application_id查找OCR累计结果指定license字段,如果没有,结束
result_class
=
HILSEOCRResult
if
application_entity
in
consts
.
HIL_SET
else
AFCSEOCRResult
ca_result_class
=
HILOCRResult
if
application_entity
in
consts
.
HIL_SET
else
AFCOCRResult
ca_ocr_res_dict
=
ca_result_class
.
objects
.
filter
(
application_id
=
application_id
)
.
values
(
*
consts
.
CA_ADD_COMPARE_FIELDS_PRE
)
.
first
()
ocr_res_dict
=
result_class
.
objects
.
filter
(
application_id
=
application_id
)
.
values
(
*
consts
.
PRE_COMPARE_FIELDS
)
.
first
()
if
ocr_res_dict
is
None
:
return
get_empty_result
()
id_res_list
=
[]
for
field_name
in
consts
.
CA_ADD_COMPARE_FIELDS_PRE
:
if
field_name
==
consts
.
IC_OCR_FIELD
:
id_res_list
.
append
(
ca_ocr_res_dict
.
get
(
field_name
)
if
isinstance
(
ca_ocr_res_dict
,
dict
)
else
None
)
id_res_list
.
append
(
ocr_res_dict
.
get
(
field_name
))
result
=
{
"is_pass"
:
True
,
"customer_name"
:
True
,
"application_entity"
:
True
,
"de_mortgage_date"
:
True
}
return
response
.
ok
(
data
=
result
)
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