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
069b2014
authored
2025-03-31 16:27:01 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
merge
2 parents
e1604e8a
4bbb6b8a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
2 deletions
src/apps/doc/internal_urls.py
src/apps/doc/models.py
src/apps/doc/ocr/ecm.py
src/apps/doc/views.py
src/apps/doc/internal_urls.py
View file @
069b201
...
...
@@ -5,6 +5,8 @@ from . import views
urlpatterns
=
[
path
(
r''
,
views
.
DocView
.
as_view
()),
path
(
r'query/employee'
,
views
.
EmployeeView
.
as_view
()),
path
(
r'query/greenBookHistoryFile'
,
views
.
SearchGBHistoryFileView
.
as_view
()),
path
(
r'query/greenBookHistoryFile'
,
views
.
DownloadGBHistoryFileView
.
as_view
()),
path
(
r'invoice/downloadExcel'
,
views
.
InvoiceExcelView
.
as_view
()),
path
(
r'invoice/queryInfo'
,
views
.
InvoiceQueryInfoView
.
as_view
()),
path
(
r'contract/v1'
,
views
.
SEContractView
.
as_view
()),
...
...
src/apps/doc/models.py
View file @
069b201
...
...
@@ -1130,4 +1130,46 @@ class DealerMapping(models.Model):
class
Meta
:
managed
=
False
db_table
=
'dealer_mapping'
\ No newline at end of file
db_table
=
'dealer_mapping'
class
HILGreenBookHistoryFile
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
object_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"文件唯一ID"
)
object_name
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
"文件名称"
)
application_no
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请号"
)
object_type
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"文件类型"
)
customer_name
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"customer_name"
)
content_size
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"文件大小"
)
owner_name
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"owner_name"
)
input_date
=
models
.
DateTimeField
(
verbose_name
=
"上传时间"
)
modify_date
=
models
.
DateTimeField
(
verbose_name
=
"修改时间"
)
location
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
"文件位置"
)
download_finish
=
models
.
BooleanField
(
default
=
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_gb_history_file'
class
AFCGreenBookHistoryFile
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
object_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"文件唯一ID"
)
object_name
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
"文件名称"
)
application_no
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请号"
)
object_type
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"文件类型"
)
customer_name
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"customer_name"
)
content_size
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"文件大小"
)
owner_name
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"owner_name"
)
input_date
=
models
.
DateTimeField
(
verbose_name
=
"上传时间"
)
modify_date
=
models
.
DateTimeField
(
verbose_name
=
"修改时间"
)
location
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
"文件位置"
)
download_finish
=
models
.
BooleanField
(
default
=
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_gb_history_file'
situ_db_label
=
'afc'
...
...
src/apps/doc/ocr/ecm.py
View file @
069b201
...
...
@@ -168,3 +168,20 @@ class ECM(GenericView):
response
.
status_code
,
response
.
headers
,
response
.
text
))
if
'ns12:createResponse'
not
in
response
.
json
()
.
get
(
'S:Envelope'
,
{})
.
get
(
'S:Body'
,
{}):
raise
ECMException
(
'ECM upload failed: {0} , with headers: {1}'
.
format
(
response
.
json
(),
response
.
headers
))
def
search_doc_info_list
(
self
,
filePath
,
business_type
):
args
=
{
"username"
:
self
.
username
,
"password"
:
self
.
pwd
,
"docbase"
:
self
.
doc_base_map
.
get
(
business_type
),
"documentType"
:
"green_book"
,
"dql"
:
"select r_object_id, object_name,b_application_no, r_object_type,b_customer_name,r_content_size, owner_name, b_input_date, r_modify_date, b_location from green_book where b_location = '"
+
filePath
+
"'"
}
header_info
=
self
.
get_headers
()
self
.
running_log
.
info
(
"{0} search header_info:{1}"
.
format
(
self
.
log_base
,
header_info
))
self
.
running_log
.
info
(
"{0} search args_info:{1}"
.
format
(
self
.
log_base
,
args
))
response
=
requests
.
post
(
self
.
search_url
,
headers
=
header_info
,
json
=
args
,
verify
=
False
)
if
response
.
status_code
!=
200
:
raise
ECMException
(
'ECM search failed with code: {0}'
.
format
(
response
.
status_code
))
self
.
running_log
.
info
(
"{0} search response.json():{1}"
.
format
(
self
.
log_base
,
response
.
json
()))
return
response
.
json
()
\ No newline at end of file
...
...
src/apps/doc/views.py
View file @
069b201
...
...
@@ -55,6 +55,8 @@ from .models import (
AFCSEOCRResult
,
HILCmsStatusInfo
,
AFCCmsStatusInfo
,
HILGreenBookHistoryFile
,
AFCGreenBookHistoryFile
,
Configs
)
from
common.exceptions
import
(
NoPermissionException
)
...
...
@@ -64,7 +66,7 @@ from . import consts
from
apps.account.authentication
import
OAuth2AuthenticationWithUser
from
celery_compare.tasks
import
compare
,
fsm_compare
from
prese.compare
import
get_empty_result
from
apps.doc.ocr.ecm
import
ECM
import
time
from
django.http
import
HttpResponse
from
django.utils.encoding
import
escape_uri_path
...
...
@@ -2066,4 +2068,57 @@ class EmployeeView(GenericView):
self
.
running_log
.
info
(
'[query Employee] [application_id={0}] [income_keywords={1}]'
.
format
(
application_id
,
income_keywords
))
if
income_keywords
is
not
None
and
len
(
income_keywords
)
>
0
:
return
response
.
ok
(
data
=
True
)
return
response
.
ok
(
data
=
False
)
class
SearchGBHistoryFileView
(
GenericView
):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
@use_args
(
employee_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
filePath
=
args
.
get
(
'filePath'
)
business_type
=
args
.
get
(
'business_type'
)
gb_history_file_class
=
HILGreenBookHistoryFile
if
business_type
in
consts
.
HIL_SET
else
AFCGreenBookHistoryFile
ecm
=
ECM
()
response_json
=
ecm
.
search_doc_info_list
(
filePath
,
business_type
)
data_objects
=
response_json
[
'Envelope'
][
'Body'
][
'executeResponse'
][
'return'
][
'dataPackage'
][
'DataObjects'
]
for
data_object
in
data_objects
:
object_id
=
data_object
[
'Identity'
][
'ObjectId'
][
'@id'
]
properties_dict
=
{}
properties
=
data_object
[
'Properties'
][
'Properties'
]
for
prop
in
properties
:
name
=
prop
[
'@name'
]
value
=
prop
.
get
(
'Value'
,
'null'
)
# 如果Value为空,则输出null
properties_dict
[
name
]
=
value
self
.
running_log
.
info
(
'[SearchGBHistoryFileView] [properties_dict={0}] '
.
format
(
properties_dict
))
gb_history_file_class
.
objects
.
create
(
object_id
=
object_id
,
object_name
=
properties_dict
.
get
(
'object_name'
,
''
),
application_no
=
properties_dict
.
get
(
'b_application_no'
,
''
),
object_type
=
properties_dict
.
get
(
'r_object_type'
,
''
),
customer_name
=
properties_dict
.
get
(
'b_customer_name'
,
''
),
content_size
=
properties_dict
.
get
(
'r_content_size'
,
''
),
owner_name
=
properties_dict
.
get
(
'owner_name'
,
''
),
#input_date=properties_dict.get('b_input_date', ''),
#modify_date=properties_dict.get('r_modify_date', ''),
location
=
properties_dict
.
get
(
'b_location'
,
''
),
download_finish
=
False
)
return
response
.
ok
(
data
=
False
)
class
DownloadGBHistoryFileView
(
GenericView
):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
@use_args
(
employee_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
business_type
=
args
.
get
(
'business_type'
)
object_id
=
args
.
get
(
'object_id'
)
save_path
=
args
.
get
(
'save_path'
)
ecm
=
ECM
()
ecm
.
download
(
save_path
,
object_id
,
'green_book'
,
business_type
)
self
.
running_log
.
info
(
'[DownloadGBHistoryFileView] [args={0}] '
.
format
(
args
))
return
response
.
ok
(
data
=
False
)
\ No newline at end of file
...
...
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