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
39cc8176
authored
2025-03-28 17:30:19 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
init 5153-5234
1 parent
6349bed3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
3 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 @
39cc817
...
...
@@ -5,5 +5,7 @@ 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'contract/v1'
,
views
.
SEContractView
.
as_view
()),
]
...
...
src/apps/doc/models.py
View file @
39cc817
...
...
@@ -1130,4 +1130,28 @@ 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"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
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"
)
# 主键
application_id
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"申请id"
)
# 索引
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 @
39cc817
...
...
@@ -163,3 +163,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
+
"' order by r_modify_date desc"
}
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 @
39cc817
...
...
@@ -53,7 +53,9 @@ from .models import (
AFCOCRResult
,
AFCSEOCRResult
,
HILCmsStatusInfo
,
AFCCmsStatusInfo
AFCCmsStatusInfo
,
HILGreenBookHistoryFile
,
AFCGreenBookHistoryFile
)
from
.named_enum
import
ErrorType
,
AutoResult
,
WholeResult
,
RPAResult
,
SystemName
,
RequestTeam
from
.mixins
import
DocHandler
,
MPOSHandler
,
PreSEHandler
...
...
@@ -61,7 +63,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
...
...
@@ -1876,4 +1878,51 @@ 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
(
application_id
=
properties_dict
[
'b_application_no'
],
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
):
filePath
=
args
.
get
(
'filePath'
)
business_type
=
args
.
get
(
'business_type'
)
ecm
=
ECM
()
ecm
.
download
(
filePath
,
business_type
)
gb_history_file_class
=
HILGreenBookHistoryFile
if
business_type
in
consts
.
HIL_SET
else
AFCGreenBookHistoryFile
gb_history_file_class
.
objects
.
create
(
application_id
=
gb_history_file_class
.
application_id
,
download_finish
=
False
)
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